473,327 Members | 2,103 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,327 software developers and data experts.

Datagird Issue - ASP 1.1

9
Hi
Not sure if this is answered b4.

I have a label, 2 textboxes and 1 check box in a datagrid . If I check the checkbox 2nd textbox should be disabled.

Is there any way I could do this in javascript(client side). I tried to do in the server side it doesnt work and also when posting back the checkbox check mark disappears.

Pls. suggest me a solution

Thanks
GV
Mar 13 '07 #1
3 1067
bergy
89
This is the .NET forum but I guess a little javascript wouldn't hurt our resident microsoft monkies... oops i mean forum admin :) i kid i kid

Try this:
Here is a javascript to disable a text box named "textbox2":
Expand|Select|Wrap|Line Numbers
  1. <script language="javascript">
  2.     function DisableTwo(){        
  3.         if(document.getElementById('checkbox1').checked){
  4.             document.getElementById('textbox2').disabled = true;
  5.         }else{
  6.             document.getElementById('textbox2').disabled = false;
  7.         }        
  8.     }
  9. </script>
Here is a sample checkbox (with the javascript function in the 'onClick' event) and a textbox to disable:
Expand|Select|Wrap|Line Numbers
  1. <input type="checkbox" name="checkbox1" id="checkbox1" onClick="javascript:DisableTwo();" />
  2. <input type="text" name="textbox2" id="textbox2" />
Happy Coding!

Adam

Hi
Not sure if this is answered b4.

I have a label, 2 textboxes and 1 check box in a datagrid . If I check the checkbox 2nd textbox should be disabled.

Is there any way I could do this in javascript(client side). I tried to do in the server side it doesnt work and also when posting back the checkbox check mark disappears.

Pls. suggest me a solution

Thanks
GV
Mar 13 '07 #2
gvi
9
Thanks Adam for the quickie. But both the textbox and checkbox are in a datagrid and if i select a chekcbox in 3rd row then the 2nd textbox in that same row should be disabled.

Hope I have expalined it clear.
Mar 13 '07 #3
bergy
89
Okay so say you have your textboxes and check boxes named based on their row index? Something like this should work:

Expand|Select|Wrap|Line Numbers
  1. <script language="javascript">
  2.     function DisableTwo(index){        
  3.         if(document.getElementById('checkbox'+index).checked){
  4.             document.getElementById('textbox'+index).disabled = true;
  5.         }else{
  6.             document.getElementById('textbox'+index).disabled = false;
  7.         }        
  8.     }
  9. </script>
Expand|Select|Wrap|Line Numbers
  1. <input type="checkbox" name="checkbox1" id="checkbox1" onClick="javascript:DisableTwo('1');" />
  2. <input type="text" name="textbox1" id="textbox1" />
  3.  
  4. <input type="checkbox" name="checkbox2" id="checkbox2" onClick="javascript:DisableTwo('2');" />
  5. <input type="text" name="textbox2" id="textbox2" />
  6.  
  7. <input type="checkbox" name="checkbox3" id="checkbox3" onClick="javascript:DisableTwo('3');" />
  8. <input type="text" name="textbox3" id="textbox3" />
Mar 13 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Petr Studenovsky | last post by:
Hello I made small GUI test program in Visual Basic NET for SQL communication. I need some help with these problems. problem 1) If I change some settings in datagrid from properties window...
0
by: Freddy | last post by:
I have 2 tables in a dataset. One of them is child to the other. In my dataset, I specify both default views to allowdelete = false My datasource table of the datagird is the master table...
7
by: George Hester | last post by:
Please take a look at this google artcle: http://groups.google.com/groups?hl=en&lr=&frame=right&th=55d6f4b50f5f9382&seekm=411f370d%241%40olaf.komtel.net#link9 The op was having trouble with...
2
by: Anthony Cuttitta Jr. | last post by:
We have an application that outputs several different graphs from data downloaded from our AS400. The application has worked without (this) issue for several months now, but just recently, the...
0
by: timon | last post by:
I have create a Datagird in the window form. How can I set the column name in the datagird?
2
by: Ben Rush | last post by:
Hello World, Okay, I have spent the day browsing the newsgroups and reading up on article after article concerning ViewState corruption and so forth, and I have a couple questions. We...
2
by: Gaurav Gargate | last post by:
To Group, I am creating a datagrid in an ASP.NET project (C#) at the design time. I will be adding the columns to the datagird at run time. The number of columns, name of the columns, data in...
5
by: Robert | last post by:
I have a series of web applications (configured as separate applications) on a server. There is a main application at the root and then several virtual directories that are independant...
1
by: Kiran | last post by:
Hi, Does any one know how to add a button to every row of a windows form datagird. Can anyone provide me some code on this. I have searched a lot but couldn't find any. I am posting this for...
13
by: SAL | last post by:
Hello, I'm trying to include a popup in the ItemTemplate of a gridview row. The ItemTemplate for the field contains a textbox and when the user clicks in the textbox I want a popup panel to show...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.