Let's first look at this example.
Front-end code:
<Asp: TextBox ID = "TextBox1" runat = "server" ReadOnly = "True"> </asp: TextBox>
Background code:
String Text = Request. Form ["TextBox1"]. Trim ();
In. in NET2.0, when the ReadOnly = "True" attribute is set for a TextBox on the page, assign a value to it through the client script, this value cannot be obtained when you access 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 ();
See ID, ClientID, UniqueID difference, read this article: http://www.bkjia.com/kf/201202/119612.html
From Xu Yue's column