1. After the page is submitted, keep the scroll bar position
You can add a maintainscrollpositiononpostback directive to the page instruction.
The following are the referenced contents: <%@ Page language= "C #" maintainscrollpositiononpostback= "true" autoeventwireup= "true" codefile= "..." Inherits= "..."%> |
2. After the page is loaded, move the focus to a control, just specify the form's DefaultFocus property.
The following are the referenced contents: <form id= "frm" defaultfocus= "txtUserName" runat= "Server" > ... </form> |
3. Set the default corresponding button for the form through the DefaultButton property, that is, the button that fires when the user knocks in the carriage
The following are the referenced contents: <form id= "frm" defaultbutton= "btnsubmit" runat= "Server" > ... </form> |
4. You can use the $ symbol to easily find a control using the FindControl method
The following are the referenced contents: <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 example above, use the DefaultFocus property of the form to specify the control in which the focus of the page is loaded, using the $ symbol to easily locate the Txtname
You can also use the following code to easily find the control
The following are the referenced contents:
TextBox TB = this. FindControl ("Form1$formvw$txtname") as TextBox; if (TB!= null) { Access TextBox Control } |
5. About cross-page submissions the method of obtaining a strongly typed Submission page control is shown in the original
6. To access MasterPage property members using a strongly typed method, see the original
7. We can use the properties of the validation control ValidationGroup specify the group that the validation control belongs to, and specify the validation group that the button needs to activate in the ValidationGroup property of the button.
The following are the referenced contents:
<form id= "Form1" runat= "Server" > Search Text: <asp:textbox id= "Txtsearch" runat= "Server"/> <asp:requiredfieldvalidator id= "Valsearch" runat= "Server" Controltovalidate= "Txtsearch" validationgroup= "Searchgroup"/> <asp:button id= "btnsearch" runat= "Server" text= "Search" validationgroup= "Searchgroup"/> .... Controls with validators and buttons defined </form> |