asp:TextBox control
TextBox control is used to enter data into the form that can be sent to the webserver by posting the form.
TextBox control is utilized to enter information into the shape that can be sent to the webserver by posting the frame. The frame can be posted by clicking a catch or an Image (We will cover it later). When it is rendered on the page, it is executed through <input> or <textarea> HTML tag. At the point when TextMode property is Singleline then this control is rendered as <input> HTML tag with Type property as Text, if Multiline then <textarea>, and if Password then <input> HTML tag with Type property as Password. In the event that you won't set TextMode property, it will be set to Singleline as a matter of course. Its properties like BackColor, ForeColor, BorderColor, BorderStyle, BorderWidth, Height and so on are actualized through style property of separate labels.
You can set its Text property either by setting Text properties in the .aspx page or from server side page. (different properties can likewise be set from the two pages) When AutoPostBack property of the TextBox is set to genuine, at that point Form is presented back on the server when cursor leaves the crate. On the off chance that OnTextChanged occasion has been set, this occasion will likewise fire.
|
Example -
// Singleline TextBox code
<asp:TextBox ID="TextBox1" runat="Server"
Width="300"></asp:TextBox>
// Multiline TextBox code
<asp:TextBox ID="TextBox2" runat="Server"
TextMode="multiLine"
Rows="4" Columns="50"
Text="TextBox with TextMode as Multiline">
</asp:TextBox>
// TextBox with AutoPostBack=true
<asp:TextBox ID="TextBox4"
runat="Server"
AutoPostBack="true"></asp:TextBox>
// Fires when Page Loads
protected void Page_Load(object sender, EventArgs e)
{
// Fires only when Page is not posting back
if (!IsPostBack)
{
TextBox1.Text = "Write something here.";
}
}
// Fires when Button is clicked
protected void ChangeLabelText(object sender, EventArgs e)
{
Label1.Text = TextBox1.Text;
}
// Fires when TextChanges in the box
protected void FireTextChange(object sender, EventArgs e)
{
TextBox1.Text = "OnTextChanged event fired";
TextBox2.Text = TextBox3.Text;
}
0 comments:
Post a Comment