If Page.IsPostBack =FalseThen Try SetFormFocus(txtUsername) Catch 'control not there or error setting focus EndTry EndIf
Dim objSystemMessages AsNew SystemMessageController lblLogin.Text = objSystemMessages.FormatSystemMessage(PortalId, "MESSAGE_LOGIN_INSTRUCTIONS", UserId)
End Sub
二,打开页面时自动将焦点放到指定位置
'set focus to any control PublicSub SetFormFocus()Sub SetFormFocus(ByVal control As Control) IfNot control.Page IsNothingAnd control.Visible Then If control.Page.Request.Browser.JavaScript =TrueThen
' convert datareader to dataset '转换DATAREADER为dataset PublicFunction ConvertDataReaderToDataTable()Function ConvertDataReaderToDataTable(ByVal reader As IDataReader) As DataTable
' create datatable from datareader Dim objDataTable AsNew DataTable Dim intFieldCount AsInteger= reader.FieldCount Dim intCounter AsInteger For intCounter =0To intFieldCount -1 objDataTable.Columns.Add(reader.GetName(intCounter), reader.GetFieldType(intCounter)) Next intCounter
' populate datatable objDataTable.BeginLoadData() Dim objValues(intFieldCount -1) AsObject While reader.Read() reader.GetValues(objValues) objDataTable.LoadDataRow(objValues, True) EndWhile reader.Close() objDataTable.EndLoadData()