Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load RetainScrollPosition() End Sub 3. DataList使用不同风格的模板
Private Sub SetFocus(ByVal controlToFocus As Control) Dim scriptFunction As New StringBuilder Dim scriptClientId As String
scriptClientId = controlToFocus.ClientID scriptFunction.Append("<script language='javascript'>") scriptFunction.Append("document.getElementById('" & scriptClientId & "').focus();") scriptFunction.Append("</script>") RegisterStartupScript("focus", scriptFunction.ToString()) End Sub
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If (Page.IsPostBack = False) Then SetFocus(TextBox1) End If End Sub
Sub Page_Load() Dim i as Integer For i=0 to 4 Dim myUserControl as Control myUserControl = Page.LoadControl(“foo.ascx”) PlaceHolder1.Controls.Add(myUserControl) PlaceHolder1.Controls.Add(New LiteralControl(“<br>”)) Next i End Sub