.
The. aspx code is as follows:
<%@ page language= "C #" autoeventwireup= "true" codefile= "TextBox_test.aspx.cs" inherits= "Textbox_test"%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title></title>
<body>
<form id= "Form1" runat= "Server" >
This is an HTML input control: <input id= "Text1" type= "text"/><br/>
This is an ASP Standard server control: <asp:textbox id= "TextBox1" runat= "Server" ></asp:TextBox>
<br/>
This is an HTML control with the Runat property: <input id= "Text2" type= "text" runat= "server"/><br/>
<asp:button id= "Button1" runat= "Server" text= "Change the value of the first text box (daemon cannot)"
/>
<br/>
<asp:button id= "Button2" runat= "Server" text= "Change the value of a second text box"
onclick= "Button2_Click"/>
<br/>
<asp:button id= "Button3" runat= "Server" text= "Change the value of a third text box"
onclick= "Button3_Click"/>
</form>
</body>
The. Aspx.cs code is as follows:
Using system;using system.collections.generic;using system.linq;using system.web;using System.Web.UI;using System.web.ui.webcontrols;public partial class textbox_test:system.web.ui.page{protected void Page_Load (object Sende R, EventArgs e) {} protected void button2_click (object sender, EventArgs e) {TextBox1.Text = DateTime . Now.tolongdatestring (); } protected void Button3_Click (object sender, EventArgs e) {text2.value = DateTime.Now.ToString (); }}
Spit Down:
The. aspx code is as follows:
<%@ page language= "C #" autoeventwireup= "true" codefile= "Sample 3-02.aspx.cs" inherits= "Sample_3_1"%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<link href= "Stylesheet.css" rel= "StyleSheet" type= "Text/css"/>
<title></title>
<body>
<form id= "Form1" runat= "Server" >
<div>
<div class= "D1" > Single-line text box:
<asp:textbox id= "txt_s" runat= "Server" enabled= "false" ></asp:TextBox>
<asp:button id= "btn_reads" runat= "server" text= "read content and display"
onclick= "Btn_reads_click"/>
</div>
<div class= "D1" > Multi-line text box:
<asp:textbox id= "txt_m" runat= "Server" textmode= "MultiLine"
height= "200px" width= "200px" ></asp:TextBox>
<asp:button id= "Btn_readm" runat= "server" text= "read content and display"
onclick= "Btn_readm_click"/>
</div>
<div class= "D1" > Password text box:
<asp:textbox id= "txt_p" runat= "Server" textmode= "Password" ></asp:TextBox>
<asp:button id= "BTN_READP" runat= "server" text= "read content and display"
onclick= "Btn_readp_click"/>
</div>
<div class= "d1" >html text box:
<input id= "txt_html" type= "text" runat= "Server"/>
<asp:button id= "btn_readhtml" runat= "server" text= "read content and display"
onclick= "Btn_readhtml_click"/>
</div>
<br/> <br/> <br/>
The layer that displays the result:
<div id= "Div_result" runat= "Server" > </div>
</div>
</form>
</body>
The. Aspx.cs code is as follows:
Using system;using system.collections.generic;using system.linq;using system.web;using System.Web.UI;using System.web.ui.webcontrols;public partial class sample_3_1:system.web.ui.page{ protected void Page_Load (object sender, EventArgs e) { } protected void Btn_reads_click (object sender, EventArgs e) { // The InnerText property of the Div is called; note that many other HTML controls have innertext properties, such as <p>,<span>,<td> Div_result. InnerText = Txt_s.text; } protected void Btn_readhtml_click (object sender, EventArgs e) { div_result. InnerText = txt_html. Value; } protected void Btn_readm_click (object sender, EventArgs e) { div_result. InnerText = Txt_m.text; } protected void Btn_readp_click (object sender, EventArgs e) { div_result. InnerText = Txt_p.text; }}
The whole study of Asp.net--textbox property