1.1 vs 2.0 Textbox Control Text on Postback
am 28.12.2007 14:59:03 von JohnWalker
Hi,
In asp.net 1.1 I use this bit of code to get the text from a textbox in a
datagrid on postback:
txtComments = CType(dgi.FindControl("txtComments"),
System.Web.UI.WebControls.TextBox)
We recently upgraded our application to the 2.0 .net framework and this code
no longer seems to work. It is a read-only textbox... the text is
added/changed with javascipt. When we set readonly property on the textbox
to False we are then able to successfully view the added/changed text on
postback. Did something change in 2.0 so that readonly text does not
postback? is there a way to get around it?
Thanks,
John
Re: 1.1 vs 2.0 Textbox Control Text on Postback
am 28.12.2007 15:12:14 von mark
"John Walker" wrote in message
news:ABC86370-171F-4F8B-86E0-44861D078EC3@microsoft.com...
> Did something change in 2.0 so that readonly text does not postback?
Yes:
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedb ack.aspx?FeedbackID=102065
> is there a way to get around it?
Yes.
Instead of this:
do this:
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
Re: 1.1 vs 2.0 Textbox Control Text on Postback
am 28.12.2007 15:55:01 von JohnWalker
Awesome. Don't know why that works any different, but if it works then great.
Thanks!
"Mark Rae [MVP]" wrote:
> "John Walker" wrote in message
> news:ABC86370-171F-4F8B-86E0-44861D078EC3@microsoft.com...
>
> > Did something change in 2.0 so that readonly text does not postback?
>
> Yes:
> http://connect.microsoft.com/VisualStudio/feedback/ViewFeedb ack.aspx?FeedbackID=102065
>
> > is there a way to get around it?
>
> Yes.
>
>
> Instead of this:
>
>
>
>
> do this:
>
>
>
>
> 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
>
>