Changing properties of textbox in visual studio 2010
To change the properties of the textbox at run time we need a textbox whose properties we will be changed and an event on which we can see the changes that we have made are applied so to solve the purpose of an event I have taken a command button or button whose click event will work for as the triggering event.
A Design view is shown here.
There are three controls:
And following changes are made to their properties.
Label1
ID: lbl_Name
Backcolor: Aqua
BorderColor: #660066
BorderStyle: Double
BorderWidth: 5px
Font:
Bold: True
Italic: True
Name: Book Antiqua
ForeColor: Red
Text: Name
ToolTip: Enter Your First Name
Textbox1
ID: txt_name
Accesskey: n
Button1
ID : btn_click
Text: Click
Then you can either double click on the button in the Default.aspx page or you can double click on the combobox in the properties window under events in front of click event in order to generate the click event.
Once you will do that you will see the following window.
And in this window you can write the following code.
This will change the mode of the textbox to multiline and the text as well.
The following code will be executed when the text of the textbox will be changed but here is a catch if you will not change the autopostback property of the textbox to true this event wont execute and the default value for autopostback is false as in most of the cases we do not prefer a textbox to call the code form the server side.
In this article I will be talking about the few most commonly used properties of the textbox control. Some of the properties are similar as the label control which you can find here or on the mirror link
Rest of the properties I will deal in this article
Property Purpose
IDto change the name of the control which we use in code file
AccessKeythe shortcut key used with the combination of alt to access the control at runtime
Columnsto set how many charters will be displayed in the textbox
Rowsto set how many lines will be displayed in the textbox
Enabledtrue or false to set whether the control can be accessed by the user at runtime or not
MaxLenghtto define how many characters can be entered in the textbox if it is 0 that means no limit is set
ReadOnlytrue or false to set that the value of control is not changed at runtime by the user
If true user can't change the value
TextModeSingle: user can enter value in one line
Multiline: user can use the enter key to insert new line and type in the new line
Password: acts like a password field the actual characters will not be displayed
To change the properties of the label at run time we need a label whose properties we will change and an event on which we can see the changes that we have made are applied so to solve the purpose of an event I have taken a command button or button whose click event will work for as the triggering event.
A Design view is shown here.
There are three controls:
And following changes are made to their properties.
Label1
ID: lbl_Name
Backcolor: Aqua
BorderColor: #660066
BorderStyle: Double
BorderWidth: 5px
Font:
Bold: True
Italic: True
Name: Book Antiqua
ForeColor: Red
Text: Name
ToolTip: Enter Your First Name
Label2
ID: lbl_result
Button1
ID : btn_click
Text: Click
Then you can either double click on the button in the Default.aspx page or you can double click on the combobox in the properties window under events in front of click event in order to generate the click event.
Once you will do that you will see the following window.
Add the following code to the event and run the project