The TextBox Control is used to create a text box for users to enter text. The properties and features of TextBox are listed in our web Control Reference Manual. The following example demonstrates some attributes of the TextBox Control that you may use:
The TextBox Control is used to create a text box for users to enter text.
The properties and features of TextBox are listed in our web Control Reference Manual.
The following example demonstrates some attributes of the TextBox Control that you may use:
<Html>
<Body>
<Form runat = "server">
Basic TextBox:
<Asp Tutorial: TextBox id = "tb1" runat = "server"/>
<Br/>
TextBox used to enter the password:
<Asp: TextBox id = "tb2" TextMode = "password" runat = "server"/>
<Br/>
TextBox with text:
<Asp: TextBox id = "tb4" Text = "Hello World! "Runat =" server "/>
<Br/>
TextBox with multiple rows:
<Asp: TextBox id = "int32" TextMode = "multiline" runat = "server"/>
<Br/>
TextBox with height:
<Asp: TextBox id = "tb6" rows = "5" TextMode = "multiline"
Runat = "server"/>
<Br/>
TextBox with width:
<Asp: TextBox id = "tb5" columns = "30" runat = "server"/>
</Form>
</Body>
</Html>
During Web development, you may also encounter problems that I encountered before. When using the TextBox Control, the edge of the control cannot be completely overwritten by the background image. 1:
After Textbox resolution, it is also an html-Text control, while the Text control has edges by default, that is, border: 1px solid #000; therefore, you only need to add the following small CSS sentence to the Textbox Control, that is, "border: 0px". The final effect is 2: ②. When you are doing Web development, I don't know if you have found that when TextMode = "MultiLine" of the Textbox Control is set, MaxLength has actually expired. When the TextMode attribute of Textbox is "MultiLine", it is actually the html-textarea control after parsing. This html control does not have the MaxLength attribute. If you want to limit the input length, set the following attributes: <asp: TextBox ID = "reply_note" runat = "server" TextMode = "MultiLine" onkeyup = "this. value = this. value. slice (0, 1000) "> ③ when you make some input boxes, you may want to trigger an event when you get the focus, or trigger an event when you lose focus: I wrote two JS files to meet the following requirements:
<Script type = "text/Webpage effects">
// Triggered when the focus is obtained
Function onFocusFun (element, elementValue ){
If (element. value = elementValue ){
Element. value = "";
Element. style. color = "";
}
}
// Triggered when the input box is left.
Function onblurFun (element, elementValue ){
If (element. value = ''){
Element. style. color = "#808080 ";
Element. value = elementValue;
}
}
</Script>
Then, you can reference them in the Textbox Control as follows:
<Asp: TextBox ID = "reply_note" runat = "server" Text = "post reply, up to 1000 words entered" ForeColor = "#808080" OnFocus = "onFocusFun (this, 'Post reply, up to 1000 words ')"
OnBlur = "onblurFun (this, 'Post reply, up to 1000 words')"> </asp: TextBox>