Sub Calendar
_SelectionChanged(ByVal sender As Object
_
ByVal e As SystemEventArgs)
ProfileInfoDateSelected = CalendarSelectedDate
ProfileInfoLastModified = Now
End Sub
当页面加载时我们可以取出预先保存在profile对象中的值然后再在日历控件中显示上次用户显示的日期以及用户上次选择日期时的时间
Sub Page_Load(ByVal sender As Object _
ByVal e As SystemEventArgs) Handles MeLoad
CalendarSelectedDate = ProfileInfoDateSelected
ResponseWrite(Date set on ProfileInfoLastModified)
End Sub
而为了在每次页面加载时能根据之前用户保存在profile对象中的语言正确显示网页必须在page_preinit()事件中写入如下代码
Dim lang As SystemGlobalizationCultureInfo
读取用户在下拉框中选取的语言值
Dim selectedLang As String = Request(ddlLanguage)
如果用户选择auto则在下拉框中显示AUTO的选择项
If selectedLang = Auto Then
ddlLanguageSelectedIndex =
Exit Sub
End If
如果是POSTBACK则读取原来已经保存的语言信息
If selectedLang IsNot Nothing Then
lang = New SystemGlobalizationCultureInfo(selectedLang)
Else
如果是第一次调用页面
If Profilelanguage <> Auto Then
lang = New SystemGlobalizationCultureInfo(Profilelanguage)
Select Case Profilelanguage
Case enUS : ddlLanguageSelectedIndex =
Case zhCN : ddlLanguageSelectedIndex =
Case auto : ddlLanguageSelectedIndex =
End Select
Else
if language is auto then exit
ddlLanguageSelectedIndex =
Exit Sub
End If
End If
SystemThreadingThreadCurrentThreadCurrentCulture = lang
SystemThreadingThreadCurrentThreadCurrentUICulture = lang
lblWelcomeMessageText = ResourcesResourceWelcomeMsgToString
PageTitle = ResourcesResourcePageTitleToString
lblSelectLanguageText = ResourcesResourceSelectLanguageToString
下面来解释一下代码首先声明一个cultureinfo类型的变量这个变量将保存用户每次选择语言后的信息
[] [] [] []