Tips for ASP. net2.0

Source: Internet
Author: User

1. After submitting the page, keep the position of the scroll bar
You can add the maintainscrollpositiononpostback command to the page command.

Reference content is as follows:
<% @ Page Language = "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.

Reference content is as follows:
<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

Reference content is as follows:
<Form ID = "frm" defaultbutton = "btnsubmit" runat = "server">
...
</Form>

4. You can use the $ symbol to easily find the control using the findcontrol method.

Reference content is as follows:





name:
text = '<% # eval ("firstname") + "+ eval (" lastname ") %> '/>



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

Reference content is as follows:

Textbox TB = This. findcontrol ("form1 $ formvw $ txtname") as textbox;
If (TB! = NULL)
{
// Access Textbox Control
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.