Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / December 2007

Tip: Looking for answers? Try searching our database.

1.1 vs 2.0 Textbox Control Text on Postback

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Walker - 28 Dec 2007 13:59 GMT
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
Mark Rae [MVP] - 28 Dec 2007 14:12 GMT
> 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");
}

Signature

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

John Walker - 28 Dec 2007 14:55 GMT
Awesome.  Don't know why that works any different, but if it works then great.
Thanks!

> > Did something change in 2.0 so that readonly text does not postback?
>
[quoted text clipped - 19 lines]
>     MyTextBox.Attributes.Add("readonly", "readonly");
> }

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.