473,395 Members | 1,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

1.1 vs 2.0 Textbox Control Text on Postback

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

Dec 28 '07 #1
2 1404
"John Walker" <Jo********@discussions.microsoft.comwrote in message
news:AB**********************************@microsof t.com...
Did something change in 2.0 so that readonly text does not postback?
Yes:
http://connect.microsoft.com/VisualS...dbackID=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

Dec 28 '07 #2
Awesome. Don't know why that works any different, but if it works then great.
Thanks!

"Mark Rae [MVP]" wrote:
"John Walker" <Jo********@discussions.microsoft.comwrote in message
news:AB**********************************@microsof t.com...
Did something change in 2.0 so that readonly text does not postback?

Yes:
http://connect.microsoft.com/VisualS...dbackID=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

Dec 28 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: RTM | last post by:
Can anyone help me with the following issue? I've seen some similar questions here, but none relating to a textbox control.... I have a form with several controls, one of them being a textbox...
4
by: Gill Smith | last post by:
After setting the web control text box enable property to FALSE makes the control to loose the data between round trip. I am making sure that the property - EnableViewState = TRUE. Same code...
0
by: Dot net work | last post by:
Hi, Make up a very simple project as follows: 1 aspx form 3 web user controls (referred to as A, B, and C) "A" web user control: Put 1 textbox and 1 button on this web user control. (You...
4
by: Dave | last post by:
Well... with data in the textbox.. This did not work... <asp:TableCell ID="Tablecell1" CssClass="lnk_results" Runat="server" Width="35%" HorizontalAlign="Left" ColumnSpan="5"> <asp:TextBox...
0
by: datakix | last post by:
After 16 hours of frustration, I've managed to solve this problem for a project I'm working on. The 'trick' is set EnableViewState="False" for the asp:textbox inside the Repeater control. The...
4
by: MattB | last post by:
Hi. I'm working on an intranet application that requires a user to input information about themselves. I have a user control with a couple of textboxes that I want the user to enter their weight...
6
by: HockeyFan | last post by:
I'd like to have an AJAX textbox that after the user fills in, will auto-fill another textbox on the page without having a postback occur. It doesn't have to do any filtering or any other thing...
6
by: john | last post by:
I have the following textbox setup with Text & ToolTip Bindings as follows; I'm using Visual Studio 2008 VB: <asp:TextBox ID="txtDay1" runat="server" Text='<%# Eval("Day1") %>'...
9
by: David C | last post by:
I have an asp.net page that contains a FormView with several controls bound to a SqlDataSource. One of the controls is a TextBox bound to a date column. I have the following additional properties...
7
by: adiel_g | last post by:
Hello Everyone, I created a custom control. On the CreateChildControls, I added a textbox to the control as follows: // TextBox TextBox txtValue = new TextBox(); txtValue.ID = "txtValue"; ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.