Wrox Programmer Forums
|
Classic ASP Basics For 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 19th, 2004, 09:55 AM
Authorized User
 
Join Date: Apr 2004
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with DataGrid & JavaScript

Hi,

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;
    }

Thanks in advance,
Qadeer.

 
Old April 19th, 2004, 10:22 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

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)

 
Old April 19th, 2004, 10:28 AM
Authorized User
 
Join Date: Apr 2004
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks again Imar.. I didn't realize that this forum was for classic ASP...

Qadeer






Similar Threads
Thread Thread Starter Forum Replies Last Post
JavaScript & XML & NN lmod Javascript How-To 0 August 18th, 2005 03:16 PM
Javascript && keeps turnig into && ayrton Pro VB.NET 2002/2003 3 June 27th, 2005 03:34 PM
Tricky Javascript/XSL '&' problem...... robster Javascript How-To 1 January 23rd, 2004 02:11 PM
xml & javascript shine Javascript How-To 0 December 24th, 2003 07:25 AM
Treeview & Javascript menu problem lbob Classic ASP Professional 0 September 17th, 2003 10:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.