Classic ASP BasicsFor beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
I am using a datagrid web control to display some data. One of the columns in this datagrid has text boxes which displays data and the user can change the data listed here. I also have a checkbox outside the datagrid which when checked, the textboxes in that particular column are disabled. I am using javascript to accomplish this. (document.getElementById("TextBox1").disabled = true;)
Now consider this scenario: Let's say that the data displayed in the first textbox of that particular column is '1'(on page load). If the user changes this to '2' and checks the checkbox that disables the textbox displaying this data and then clicks the submit button, I want to display '2' in that textbox after postback. To do this Iam trying to read this value from the webpage using the code shown below. But when the textboxes in that column of the datagrid have been disabled by javascript, this particular snippet of code that I am using to get the value in that textbox returns a null value. (This doesn't happen with any text box outside the datagrid. Neither does it happen when the text boxes in that column of datagrid are enabled).
Is there a way to work around this or is there any other solution to this problem?
Code:
foreach (DataGridItem DG_Item in DataGrid1)
{
text1 = ((TextBox)DG_item.FindControl("TextBox1")).Text;
}
I think you're better off asking these kind of .NET questions in an ASP.NET forum. This for is for classic ASP, not ASP.NET.
Anyway, I think that disabled controls do not participate in postback. That is, the browser doesn't add them to the form collection when it submits the page. You can set the textbox to ReadOnly instead. This will prohibit the user from changing the value, while the field will still be submitted.
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Loose Joints by This Mortal Coil (Track 5 from the album: Blood)