Home > DeveloperSection > Articles > TextBox Control in ASP.Net

TextBox Control in ASP.Net


ASP.Net ASP.Net 
Ratings:
0 Comment(s)
 4204  View(s)
Rate this:

TextBox Control in ASP.Net

The TextBox server control is an input control that lets the user enter text.

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

TextBox Control in ASP.Net

<asp:TextBox ID="TextBox1" runat="server">Hello</asp:TextBox>

                        Or

<asp:TextBox ID="TextBox1" runat="server" Text="Hello"></asp:TextBox>

TextBox Control in ASP.Net

 You can also set the TextMode property to SingleLine MultiLine or Password. By default, the TextMode property is set to SingleLine, which creates a text box with only one line.

 MultiLine creates a text box with more than one line.

TextBox Control in ASP.Net

Password creates a single-line text box that masks the value entered by the user.

TextBox Control in ASP.Net TextBox Control in ASP.Net

Use the Max Length property to determine the contents of the TextBox control. You can limit the number of characters that can be entered in the control by setting the MaxLength property.

TextBox Control in ASP.Net

Here we set MaxLength 10, after 10 characters you will not be able to enter text in textbox

We can change textbox UI

<asp:TextBox ID="TextBox1" runat="server" Font-Bold="True" Font-Italic="True"

 Font-Names="Arial" ForeColor="#FF33CC"></asp:TextBox>

TextBox Control in ASP.Net TextBox Control in ASP.Net

TextBox Event:

Name

Description

TextChanged

Occurs when the content of the text box changes between posts to the server.

 

TextChanged event fire when you write any text in textbox

  <asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True"

        ontextchanged="TextBox1_TextChanged"></asp:TextBox>

   

    <asp:Label ID="Label1" runat="server"></asp:Label>

protected void TextBox1_TextChanged(object sender, EventArgs e)

    {

        Label1.Text = TextBox1.Text;

    }

 

Now execute the website

Write any text in textbox and click outside of the textbox then TextChanged event  fire and written text will show in Label.

TextBox Control in ASP.Net


Don't want to miss updates? Please click the below button!

Follow MindStick