Saturday 18 August 2012

.Net Beginners : Make the TextBox readonly

As a .Net Beginners you must know how to make textbox readonly.

You can make textbox read only. Means do not allow type text in textbox and also is there is any text predefined in that you are not able to change that text.
You can do this with the help of "ReadOnly" property. You can set ReadOnly=true to make textbox read only.
By default text box is not readonly.

Here is example for this.
In this example we have one text box and we make that textbox readonly.
You can set this property from aspx side or from Coding side.
In this example we are showing from both side

ASPX Code:
<asp:TextBox runat="server" ID="txtProductName" Text="Keyboard"  ></asp:TextBox>

C# Examples :
txtProductName.ReadOnly = true;

VB.net Examples :
txtProductName.ReadOnly = True

Output : 


You can use Either aspx side or Coding side approach.

This is very useful articles for Beginning .Net .

This type of C# Tips is very useful in day to day programming life.

Note : Give Us your valuable feedback in comments. Give your suggestions in this article so we can update our articles accordingly that.


No comments:

Post a Comment