Notes for using request. Form in Asp.net

Source: Internet
Author: User

Let's first look at this example.

Front-endCode:

<ASP: textboxId = "textbox1" Runat="Server" Readonly="True" > </ASP: textbox>

Background code:

String text =Request. Form ["textbox1"].Trim ();

 

In. net2.0, when the readonly = "true" attribute is set for a textbox on the page,After being assigned a value through a client script, you cannot obtain this value when accessing the text attribute in the background code.After trying, we found that the problem can be solved in the following ways:

 

When we use a form to obtain a control in a form, we actually use the name. This is the initial principle of HTML. J2EE is used in this way. So how can we use ID in Asp.net? In fact, Asp.net automatically assigned the ID to the name.

 

However, a problem occurs:

If there is a nested condition, such as the master page and the gridview, the control name will change.Then we must first obtain the uniqueid.

String uid = this.txt birth. uniqueid;
String value = request. Form [uid]. Trim ();

 

Check the difference among ID, clientid, and uniqueid.Article:Http://blog.csdn.net/woshixuye/article/details/7259833 

 

 

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.