---
title: "TextBox Control in ASP.Net"  
description: "The TextBox server control is an input control that lets the user enter text.  Hello  Or   You can also set the TextMode property to SingleLine MultiL"  
author: "Pushpendra Singh"  
published: 2010-10-11  
updated: 2020-03-04  
canonical: https://www.mindstick.com/articles/157/textbox-control-in-asp-dot-net  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 2 minutes  

---

# TextBox Control in ASP.Net

The [TextBox](https://www.mindstick.com/articles/320/textbox-control-in-vb-dot-net) server [control](https://yourviews.mindstick.com/view/83439/bipartisan-gun-control-bill-passed-in-us-after-decades) is an input control that lets the user enter text.\

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

![TextBox Control in ASP.Net](https://www.mindstick.com/mindstickarticle/a401d106-32c9-4917-b148-48b340689bd9/images/da3f9f35-6072-410d-bea2-60cf9e31de6a.png)

```
<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](https://www.mindstick.com/mindstickarticle/a401d106-32c9-4917-b148-48b340689bd9/images/d8418652-bbee-442d-badf-11c313f21d03.png)

You can also set the TextMode [property](https://www.mindstick.com/articles/198559/an-ownership-of-property-in-hua-hin) to SingleLine MultiLine or [Password](https://www.mindstick.com/blog/118/retriving-user-password-by-using-stored-procedure-in-asp-dot-net). By [default](https://www.mindstick.com/interview/12771/what-is-the-importance-of-default-resources), the TextMode property is set to SingleLine, which creates a text box with only [one line](https://www.mindstick.com/forum/23213/initialization-of-an-arraylist-in-one-line).

MultiLine creates a text box with more than one line.

![TextBox Control in ASP.Net](https://www.mindstick.com/mindstickarticle/a401d106-32c9-4917-b148-48b340689bd9/images/5e233c43-7f62-48ff-9b35-21efda872087.png)

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

![TextBox Control in ASP.Net](https://www.mindstick.com/mindstickarticle/a401d106-32c9-4917-b148-48b340689bd9/images/d5ca6692-f857-4ca1-8a8a-6f73f6dd4d5e.png) ![TextBox Control in ASP.Net](https://www.mindstick.com/mindstickarticle/a401d106-32c9-4917-b148-48b340689bd9/images/ebbb4d1d-5e58-4280-8ee4-2d29a20bbce7.png)

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](https://www.mindstick.com/mindstickarticle/a401d106-32c9-4917-b148-48b340689bd9/images/7c88d2a7-1633-48e1-8c28-9367db4fb939.png)

Here we set MaxLength 10, after 10 [characters](https://answers.mindstick.com/qa/42112/who-is-the-originator-of-avengers-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](https://www.mindstick.com/mindstickarticle/a401d106-32c9-4917-b148-48b340689bd9/images/6fdf5c45-af44-42f3-a4f0-0e6c58ebcc98.png) ![TextBox Control in ASP.Net](https://www.mindstick.com/mindstickarticle/a401d106-32c9-4917-b148-48b340689bd9/images/5f914a9c-247c-4957-acc3-01920c91a497.png)

## TextBox Event:

| Name | Description |
| --- | --- |
| TextChanged | Occurs when the [content](https://www.mindstick.com/articles/12369/cms-extension-for-magento-2-advanced-content-manager-2) 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](https://www.mindstick.com/interview/49/how-can-i-execute-a-php-script-using-command-line) the [website](https://yourviews.mindstick.com/view/87705/when-do-we-require-an-agency-to-drive-traffic-to-a-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](https://www.mindstick.com/mindstickarticle/a401d106-32c9-4917-b148-48b340689bd9/images/1671a356-8da8-4ac6-b241-097c97ee1887.png)

---

Original Source: https://www.mindstick.com/articles/157/textbox-control-in-asp-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
