web analytics

Tech Guidence

Guidance at Ease

TEXTBOX in ASP.Net

TEXTBOX in ASP.Net

A textbox is a control in Asp.net to input the text. A textbox is the main control which is used in all applications as all the text input is done by Textbox.

Textbox in asp.net can be added to the page by simply dragging it from inbox to the webform or by doing coding by you in HTML as given below

<asp:TextBox ID = “TextBox1″ runat = “server”> </asp:TextBox>

 

asp:Textbox here is used for the textbox control is the asp.net.

ID is the unique ID of the textbox which is used to access the textbox in the code.

runat = “server” is used to run the control on the server side.

</asp: Textbox> :- This tag is used to close the textbox tag.  

Events of Textbox

Textchanged  :-  It is the one and only event of the textbox. It will fire only when the changes are made to the text property of the textbox. This can be obtained by simply double click on the textbox or by going to property of the textbox by pressing F4 and go on events. There you will find the text changed property to the textbox. When you click on that then you will find out the code written n code file as shown below.

protected void TextBox1_TextChanged(object sender, EventArgs e)

{

}

For Example:

For simply counting the length in the textbox you can write

protected void TextBox1_TextChanged(object sender, EventArgs e)

{

Int length = Textbox1.Text.Length ;

}

Hence the length of textbox will get stored in the length and you can display it where you can to display.

Properties of TEXTBOX

ID : It is the unique ID of the textbox which is used to access the textbox in code.

AutoCompletetype :  This is to describe the type of the textbox that what we are getting as a input from textbox like Email, Cellular, Gender, Home City etc.

Autopostback :  Autopostback is the property which is used for Auto post back of the content of textbox whenever the changes are made to the textbox.  

BackColor : It is used to set the back colour of the Textbox.

BorderColor : It is used to set the Back Colour of the Textbox

BorderStyle : It is used to set the Border style of the textbox that is solid, Dashed, Groove etc.

BorderWidth : It is used to set the border width of the textbox and it will be in Pixels.

Columns : It is used to set the columns in the textbox whether  2, 3, 4 etc .

CSSclass : It is used to apply any user defined or server defined class to the textbox.

Font : It is used to set the style of the font that is bolt , italic etc .

ForeColor : It is used to set the forecolour of the textbox.

Height : It is used to set the height of the textbox.

Maxlength : It is used to set the maximum length of the textbox.

Readonly : This property is used to make the textbox read only.

Rows :  It is used to set the rows in the textbox.

Text : It is used to set the text in the textbox by default.

Textmode :  It is used to set the mode of the textbox that is single line , multi line etc.

Tooltip :  It is the property that whenever you bring the mouse on the textbox than it displays the message which helps the user to know what to write on the textbox.

Visible :  It is used to set the visibility of the textbox.

Width :  It is used to set the width of the textbox.

  These are the basic details about the textbox, its properties and events.This was the article about TEXTBOX in Aps.net

You May Also Like to Read:

Tags:

About

I am B.tech Holder and have completed my B.tech from Hisar in Electronics and communications. I am asp.net developer and certified in this language. I love to share my experience and knowledge

View all posts by

One Response

  1. Samsung Galaxy Note 4 says

    hello aman,it was really useful post to learn about asp .net.
    I also read your previous post on ASP .Net,that was also awesome.
    You are doing a great job.
    Samsung Galaxy Note 4 recently posted…Samsung Galaxy Note 4 RumorsMy Profile

POST A COMMENT


*
CommentLuv badge

a