Re: 1.1 vs 2.0 Textbox Control Text on Postback

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



"John Walker" <JohnWalker@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:ABC86370-171F-4F8B-86E0-44861D078EC3@xxxxxxxxxxxxxxxx

Did something change in 2.0 so that readonly text does not postback?

Yes:
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=102065

is there a way to get around it?

Yes.


Instead of this:

<asp:TextBox ID="MyTextBox" runat="server" ReadOnly="True" />


do this:

<asp:TextBox ID="MyTextBox" runat="server" />


and in your code behind do this:

protected void Page_Load(object sender, EventArgs e)
{
MyTextBox.Attributes.Add("readonly", "readonly");
}


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

.


Quantcast