Web server Controls->ASP.NET TextBox Control
2007-03-27 17:18
441 查看
Definition and Usage
The TextBox control is used to create a text box where the user can input text.Properties
Property | Description |
---|---|
AutoPostBack | A Boolean value that specifies whether the control is automatically posted back to the server when the contents change or not. Default is false |
Columns | The width of the textbox |
id | A unique id for the control |
MaxLength | The maximum number of characters allowed in the textbox |
OnTextChanged | The name of the function to be executed when the text in the textbox has changed |
Rows | The height of the textbox (only used if TextMode="Multiline") |
runat | Specifies that the control is a server control. Must be set to "server" |
Text | The contents of the textbox |
TextMode | SingleLine creates a text box with only one line. MultiLine creates a text box with multiple lines. Password creates a one-line text box that masks the value entered by the user. Default is SingleLine. Legal values are: SingleLine MultiLine Password |
Wrap | A Boolean value that indicates whether the contents of the textbox should wrap or not |
Examples
TextboxASPX Source:
<script runat="server"> Sub submit(sender As Object, e As EventArgs) lbl1.Text="Your name is " & txt1.Text End Sub </script> <html> <body> <form runat="server"> Enter your name: <asp:TextBox id="txt1" runat="server" /> <asp:Button OnClick="submit" Text="Submit" runat="server" /> <p><asp:Label id="lbl1" runat="server" /></p> </form> </body> </html> |
Output Result:
Enter your name: |
IF you enter your name "shaohai" into the textbox , it will shows:
Enter your name: Your name is shaohai |
Textbox 2
ASPX Source:
<script runat="server"> sub submit(sender As Object, e As EventArgs) lbl1.Text=txt1.Text end sub </script> <html> <body> <form runat="server"> <asp:TextBox id="txt1" Text="Hello World!" Font_Face="verdana" BackColor="#0000ff" ForeColor="white" TextMode="MultiLine" Height="50" runat="server" /> <asp:Button OnClick="submit" Text="Copy Text to Label" runat="server" /> <p><asp:Label id="lbl1" runat="server" /></p> </form> </body> </html> |
Hello World! |
IF you enter the text "shaohai" instead of "Hello World!", it will shows:
shaohai shaohai |
相关文章推荐
- Web Server Controls->ASP.NET ListBox Control
- Web Server Controls->ASP.NET TableCell Control
- Web Server Controls->ASP.NET AdRotator Control
- Web Server Controls->ASP.NET DropDownList Control
- Web Server Controls->ASP.NET Literal Control
- Web Server Controls->ASP.NET TableRow Control
- Web Server Controls->ASP.NET HyperLink Control
- Web Server Controls->ASP.NET Button Control
- Web Server Controls->ASP.NET Panel Control
- Web Server Controls->ASP.NET Table Control
- Web Server Controls->ASP.NET Image Control
- Web Server Controls->ASP.NET PlaceHolder Control
- Web Server Controls->ASP.NET ImageButton Control
- Web Server Controls->ASP.NET CheckBox Control
- Web Server Controls->ASP.NET Label Control
- Web Server Controls->ASP.NET RadioButton Control
- Web Server Controls->ASP.NET LinkButton Control
- Web Server Controls->ASP.NET RadioButtonList Control
- Web Server Controls->ASP.NET XML Control
- ASP.NET: Custom AutoCompleteTextBox WebControl [With Source Code]