.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Sandeep Singh
Melody Anderson
Eminent IT


TextBox Control


Introduction :

TextBox Control is used for user to enter the input like any string eg., Name, Password , number etc., Asp.NET TextBox itself is a class which is present under System.Web.UI.WebControls namespace.

TextBox Control  is used  for user to enter the input like any string eg.,  Name, Password ,  number etc.,
Asp.NET  TextBox itself is  a class which is present under System.Web.UI.WebControls namespace.

Important Proterties of Asp.NET Webserver  Textbox control are given below. You can set all these properties  at Design time or at Runtime.

AutoPostBack - Accept Boolean Value -  When it sets true that means Event automatically posted to Server

Enabled - Accept Boolean Value- Used to Get/Set TextBox Enabled

Height - Accept IntergerValue  -  Used to Set/Get height of the textbox

MaxLength - Accept  IntergerValue  - Used to Set the maximum length accepted by TextBox

ReadOnly - Accept Boolean Value -  Used to set the TextBox ReadOnly (User can not put any value to this if it sets to true)

Rows - Accept IntergerValue- Used to set the maximum number of rows accepted by the TextBox (Used In Multiline TextBox)

Text - Accept  String -  Commenly Used property to Get/Set the the text inside the TextBox. (Note: User can not see the  text when the TextMode property is set to "Password" and you are assigning value from Server)

TextMode - Enumerator -  You can set the TextBox Mode to "SingleLine", "MultiLine", "Password"

Width - Accept IntergerValue -  Used to set the width of the TextBox

Events available in Asp.Net Webserver TextBox Control are:

- This event will fire when Text is changed by the user and page posted back to server.

When Page loads, then the hierarchy of event of the TextBox looks like this:

TextBox_Init - >Page_Load - >TextBox_Load - > TextBox_PreRender -> TextBox_Unload

If User has  changed some text in TextBox then the Hirerchy will be:

TextBox_Init - >Page_Load - >TextBox_Load - > TextBox_TextChanged-> TextBox_PreRender - > TextBox_Unload

Lets See an example

Your .aspx code will look like this for a WebServer Control TextBox

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

And to assign value to the textbox programatically in Page_Load Event form the .cs file


protected void Page_Load(object sender, EventArgs e)


        MyTextBox.Text = "Hello from Page_Load Event";


Other Tutorials in the same Category:
  • CheckBoxList Control      
  • Button Control      
  • Calendar Control      
  • CheckBox Control      
  • DropDownList Control or Combobox      
  • FileUpload Control      
  • Hidden Field Control      
  • ImageButton Control      
  • Link Button Control      
  • ListBox Control      
  • Literal Control      
  • RadioButton Control      
  • RadioButtonList Control      
  • TextBox Control

    Return to Main Index Page

    Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend