I have a textbox, that programatically i set it 'Enabled = false'. When the page, after this change, get a postback, this textbox return the enabled value to true. why?
I have the textbox into a updatepanel.
I have a textbox, that programatically i set it 'Enabled = false'. When the page, after this change, get a postback, this textbox return the enabled value to true. why?
I have the textbox into a updatepanel.
If you're setting it in code-behind in the Page_Load event, you need to remember that Page_Load occurs even on postbacks. You have two options.
Place it with in a block that checks to see if the page is a postback.
if(!Page.IsPostBack)
{
TextBox1.Enabled = false;
}
or set it in Page_Init
instead.
If you're not already familiar with it, be sure you understand the Page Lifecycle. This is must-know information for ASP.NET developers. Read about it at http://msdn.microsoft.com/en-us/library/ms178472(v=vs.100).aspx
In the page_load, do the following:
If (IsPostBack) Then
Textbox1.Enabled = False
End If