USE OF TEXT BOX CONTROL IN ASP.NET

USE OF TEXT BOX CONTROL IN ASP.NET

A TextBox control is a rectangle box that is used to take user input. In simple words, a TextBox is a place where users can input some text on an asp.net webform. TextBox Control is the most useful web server control in ASP.NET. To create a TextBox we can either write code or use the drag and drop feature of the Visual Studio IDE.


Syntax of ASP.Net TextBox


<asp:TextBoxID=”TextBox1”runat=”server”></asp:TextBox>{codeBox}


The server presents it as an HTML control and provides the following code for the browser.


<input name=”TextBox1″ id=”TextBox1″ type=”text”>{codeBox}


Text Box Properties


All server-side controls have their own properties and events. The list below shows the TextBox properties.



Properties

Description

ID

Identification name of a textbox control.

Text

It is used to display text in a control.

BackColor

It is used to set the background color of a textbox control.

color

It is used to set the text color of the control.

ToolTip

It displays a text on control when mouse over on it.

TabIndex

It is used to manage the tab order of control.

CssClass

It is used to apply style control.

Enable

true/false – used to enable or disable control.

Enable Theming

true/false – It is used to enable or disable the effect of the theme on control.

CausesValidation

true/false – It is used to enable or disable validation effect on control

Visible

true/false – It is used to hide or visible control on a web page.


Important Properties of a TextBox control

MaxLenght

It is used to set the maximum number of characters that can be input in TextBox.

TextMode

Single / Multiline / Password

ReadOnly

true/false – used to enable or disable control read-only.



Set Properties? (How to set properties?)


In ASP.Net we can set the properties in two ways.


Design Time -  When you are developing, designing, or coding, where does it go Design Time?


Run time -  When you run coding, it is called Run Time.


Example –


  1. TextBox1.Backcolor=System.Drawing.Color.Yellow;
  2. TextBox1.BorderStyle=BorderStyle.Solid;
  3. TextBox1.BorderColor=System.Drawing.Color.Red;
  4. TextBox1.BorderWidth=3;
  5. TextBox1.ForeColor=System.Drawing.Color.Green;
  6. TextBox1.Font.Bold=True;
  7. TextBox1.MaxLength=10;
  8. TextBox1.TextMode=TextBox.Password;

Methods


There are three things in every control.


  1. Properties
  2. Methods
  3. Events

2. TextBox Methods


Focus - To set the cursor on a textbox.


ToString - To convert Textbox content to a string.


3. TextBox Events


Only exchange is used in the event. This happens when we change the value.


How to use TextBox in ASP.Net


Step 1 - Open Visual Studio -> Create a new blank web application.


Step 2 - Create a new web page for the textbox example.


Step 3 - Drag and drop the textbox control on the web page from the toolbox.


Step 4 - Set the ID property of the control - eg: text name, toxicity, tx mobile


Step 5 - Use the Text property used to control the text or get the text from the control.


AKASH TIMES

I AM AN ENGINEER BY PROFESSION BUT BLOGGER IS MY OLD DAYS DREAM TO CREATE MY OWN SITE FOR THOSE WHO ARE CURIOUS ABOUT MY BIRTHPLACE THEN I AM COMING FROM (INDIA). THE CURRENT CITY LIVES IN NAVI MUMBAI, INDIA

Post a Comment

IF YOU HAVE ANY PROBLEM PLEASE FELL FREE TO CONTACT US BY - AKASH TIMES

PREVIOUS POST NEXT POST