1. After submitting the page, keep the position of the scroll bar
You can add the maintainscrollpositiononpostback command to the page command.
<% @PageLanguage ="C #" Maintainscrollpositiononpostback ="True" Autoeventwireup ="True" Codefile ="..." Inherits ="..." %>
2. After loading the page, move the focus to a control. You only need to specify the defaultfocus attribute of the form.
<Form Id ="Frm" Defaultfocus ="Txtusername" Runat ="Server">...</Form>
3. Set the default button of form through the defaultbutton attribute, that is, the button triggered when you press ENTER
<Form Id ="Frm" Defaultbutton ="Btnsubmit" Runat ="Server">...</Form>
4. You can use the $ symbol to easily find the control using the findcontrol method.
< Form Id = "Form1" Runat = "Server" Defaultfocus = "Formvw $ txtname" > < Div > < ASP: formview Id = "Formvw" Runat = "Server" > < Itemtemplate > Name: < ASP: textbox Id = "Txtname" Runat = "Server" TEXT = '<% #Eval ("firstname") + "" + eval ("lastname ")%>' /> </ Itemtemplate > </ ASP: formview > </ Div > </ Form >
In the preceding example, the defaultfocus attribute of form is used to specify the focus control for page loading. You can use the $ symbol to easily locate txtname.
You can also use the followingCodeTo easily find controls
Textbox TB =This. Findcontrol ("Form1 $ formvw $ txtname")AsTextbox;If(TB! =Null){// Access Textbox Control}
5. For more information about cross-Page Submission, see the original article.
6. Use a strong type to access members of the masterpage attribute. For more information, see the original article.
7. You can use the validationgroup property of the verification control to specify the group to which the verification control belongs, and specify the verification group to be activated in the validationgroup property of the button.
form id = " form1 " runat = "server" search text: Asp: textbox id = "txtsearch" runat = "server" /> Asp: requiredfieldvalidator id = "valsearch" runat = "server" controltovalidate = "txtsearch" validationgroup = " searchgroup " /> Asp