For example, the text box that defines HTML is as follows:
<input type= "text" onclick= "Fun ()" id= "Htmltxtdate"/>
To programmatically get the value of the text box in a background C # program, an easy way is to:
Add runat= "Server" to the HTML control, and then in the background C # code:this. Control Id.value. For example:
<input type= "text" onclick= "Fun ()" id= "htmltxtdate" runat= "Server" />
Then C # inside Label1.Text = Htmltxtdate.value;
But this method does not feel very good: because this input box is HTML, add the runat= "Server" is also the servers control, it is better to simply use vs provided TextBox control, or a little sibuxiang.
Of course, sometimes it is to use HTML text box to make other things easier, but also in the background to access the value of it, how to do?
This also has a workaround: do not runat= "server", in the background code can write: request.form["Txtname"]. ToString (); You can get the value of the input box. Note: Txtname is the Name property value.
For example, the above example:<input type= "text" onclick= "Fun ()" name= "htmltxtdate" />
It is then accessed in the background as follows: Label1.Text = request.form["htmltxtdate"]. ToString ();