1. Keep the position of the scroll bar after callback
In ASP. net1.1, it is very painful to keep the position of the scroll bar after callback, especially when there is a grid in the page and you want to edit a Specific Row. The page is reloaded and must be rolled down at the top of the page to keep the page unchanged. In asp2.0, you only need to simply add the maintainscrollpostiononpostback attribute to the page attribute:
Copy aspxCodeSave the Code <% @ page Language = "C #" maintainscrollpositiononpostback = "true" autoeventwireup = "true" codefile = "" inherits = "" %> <% @ page Language = "C # "maintainscrollpositiononpostback =" true "autoeventwireup =" true "codefile =" "inherits =" "%>
2. After the page is loaded, set the default focus to the control.
This is also a very simple example, which can be completed without the help of JavaScript. If there are two textbox in the page, why do you want the user to click textbox to start inputting data? Can the cursor be placed in the textbox to input data? You can easily use the defaultfocus attribute of the htmlform control:
Copy the aspx code and save the Code <Form ID = "frm" defaultfocus = "txtusername" runat = "server">
</Form> <Form ID = "frm" defaultfocus = "txtusername" runat = "server">
</Form>
3. Click the default button when you click Enter.
In asp1.1, it is very painful to enable the user to click the "enter" key to associate the Click Event of the server segment of a button with JavaScript. Fortunately, now you can use the defaultbutton attribute of the htmlform control to set it. This attribute can also be set on the panel control. When a user moves to a different Panel on the page, click Enter to trigger the click events of different button controls.
Copy the aspx code and save the Code <Form ID = "frm" defaultbutton = "btnsubmit" runat = "server">
</Form> <Form ID = "frm" defaultbutton = "btnsubmit" runat = "server">
</Form>
4. Simple search for fixed controls.
it is very painful to search for controls by hierarchy in the page controls, but if you know how controls are fixed on the page, you can use the abbreviation "" to search for controls without writing recursive code. Please refer to the following code and pay attention to "" Usage:
copy the aspx code and save the Code
name:
text = '<% # eval ("firstname") "" eval ("lastname ") %> '/>
name:
text = '<% # eval ("firstname") "" eval ("lastname ") %> '/>
This tip can also be used when the findcontrol () function is used on the server side:
copy C # code to save the code textbox TB = this. findcontrol ("form1formvwtxtname") as textbox;