473,804 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript with Datagrid items.

I need to do some work with Javascript and my datagrid controls.

I want to do something like:
*************** *************** *************** ************
function CheckQuestion()
{
var checkBox = document.getEle mentById('_ctl0 _SecurityStanda rd');
if (checkBox.check ed)
{
dropDown = document.getEle mentById('_ctl0 _SecretQuestion ');
dropDown.disabl ed = false;
textBox = document.getEle mentById('_ctl0 _SecretQuestion Text');
textBox.value = "";
textBox.disable d = true;
}
else
{
dropDown = document.getEle mentById('_ctl0 _SecretQuestion ');
dropDown.disabl ed = true;
textBox = document.getEle mentById('_ctl0 _SecretQuestion Text');
textBox.disable d = false;
}
}
*************** *************** *************** *************** ***

The actual names are SecurityStandar d, not _ct10_SecurityS tandard.

This works fine if I know the actual name of the object.

But in a Datagrid I get something like:

<input id="JobBoardsGr id__ctl2_JobBoa rd" type="checkbox"
name="JobBoards Grid:_ctl2:JobB oard" onclick="Javasc ript:CheckQuest ion();" />

and the next row will be:

<input id="JobBoardsGr id__ctl3_JobBoa rd" type="checkbox"
name="JobBoards Grid:_ctl3:JobB oard" onclick="Javasc ript:CheckQuest ion();" />

Is there a way to know by what object is calling, what the name is and by
that, I could prepend the extra part to the name of all the other objects in
that DataGridItem?

I am setting up the object to call the function from an AttachScript from
the DataGrid
*************** *************** *************** *************** *******
Sub OnAttachScript( sender as Object, e as DataGridItemEve ntArgs)
if e.Item.ItemType = ListItemType.IT em Or _
e.Item.ItemType = ListItemType.Al ternatingItem then
Dim oImageButton as CheckBox = CType(e.Item.Fi ndControl("JobB oard"),
CheckBox)
oImageButton.At tributes.Add ("onClick","Jav ascript:CheckQu estion();")
end if
end Sub
*************** *************** *************** *************** *************** ****

Thanks,

Tom
Jul 20 '06 #1
1 3420
I figured it out.

*************** *************** *********
function CheckJobBoard(m e)
{
temp = me.id.replace(" _JobBoard","_Ov erride");
override = document.getEle mentById(temp);
if (me.checked == true)
{
override.disabl ed = false;
}
else
{
override.disabl ed = true;
}
*************** *************** ************

Called by:

Dim oImageButton as CheckBox = CType(e.Item.Fi ndControl("JobB oard"),
CheckBox)
oImageButton.At tributes.Add ("onClick","Jav ascript:CheckJo bBoard(this);")

The interesting thing I found out was that if I set a checkbox.enable d =
"false" in the code or enable="false" in the <asp:Checkbox.. . tag, the
javascript will not work.

This is not the case with TextBoxes, however. I can initially set it
(enabled=false) and then change back and forth with javascript.

Not sure why this is the case.

Tom

"tshad" <ts**********@f tsolutions.comw rote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
>I need to do some work with Javascript and my datagrid controls.

I want to do something like:
*************** *************** *************** ************
function CheckQuestion()
{
var checkBox = document.getEle mentById('_ctl0 _SecurityStanda rd');
if (checkBox.check ed)
{
dropDown = document.getEle mentById('_ctl0 _SecretQuestion ');
dropDown.disabl ed = false;
textBox = document.getEle mentById('_ctl0 _SecretQuestion Text');
textBox.value = "";
textBox.disable d = true;
}
else
{
dropDown = document.getEle mentById('_ctl0 _SecretQuestion ');
dropDown.disabl ed = true;
textBox = document.getEle mentById('_ctl0 _SecretQuestion Text');
textBox.disable d = false;
}
}
*************** *************** *************** *************** ***

The actual names are SecurityStandar d, not _ct10_SecurityS tandard.

This works fine if I know the actual name of the object.

But in a Datagrid I get something like:

<input id="JobBoardsGr id__ctl2_JobBoa rd" type="checkbox"
name="JobBoards Grid:_ctl2:JobB oard" onclick="Javasc ript:CheckQuest ion();"
/>

and the next row will be:

<input id="JobBoardsGr id__ctl3_JobBoa rd" type="checkbox"
name="JobBoards Grid:_ctl3:JobB oard" onclick="Javasc ript:CheckQuest ion();"
/>

Is there a way to know by what object is calling, what the name is and by
that, I could prepend the extra part to the name of all the other objects
in that DataGridItem?

I am setting up the object to call the function from an AttachScript from
the DataGrid
*************** *************** *************** *************** *******
Sub OnAttachScript( sender as Object, e as DataGridItemEve ntArgs)
if e.Item.ItemType = ListItemType.IT em Or _
e.Item.ItemType = ListItemType.Al ternatingItem then
Dim oImageButton as CheckBox = CType(e.Item.Fi ndControl("JobB oard"),
CheckBox)
oImageButton.At tributes.Add ("onClick","Jav ascript:CheckQu estion();")
end if
end Sub
*************** *************** *************** *************** *************** ****

Thanks,

Tom

Jul 20 '06 #2

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

Similar topics

2
4339
by: pei_world | last post by:
I want to implement a key hit with enter to dropdown a combobox that is in the datagrid. in this case I need to override its original behaviours. I found some codes from the web. Does anyone know how to use this code? please help! http://www.experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q_20862953.html
2
3196
by: john | last post by:
I posted this question to comp.lang.javascript but didn't get a response, so I'll try here. I am using ASP.NET and I have a datagrid. One of the columns in my grid is all checkboxes. When the user clicks on a certain button on the page, which is not in the grid, I want to be able to traverse through all the checkboxes in that column and see how many are checked. This is so that I can give them a confirmation dialog before I do an action...
19
2486
by: Sjaakie Helderhorst | last post by:
Hello, I need to add a Javascript event (onClick) to a servercontrol (asp:checkbox). Checkbox is named 'cbDoMail'. Assumed that 'cbDoMail.Attributes.Add("onClick", "doJavascriptThing()") would do the job, unfortunately it didn't. Can anyone point me in the right direction? Thanks!
9
5068
by: tshad | last post by:
How do I find (and set) a couple of labels in the Footer after a DataGrid is filled? I have a bunch of DataGrids that get displayed nested inside a DataList. The datagrid looks like: ******************************************************************************* <asp:DataGrid visible="False" border=1
4
3523
by: John Boy | last post by:
Hi, Can anyone help. This is really doing my nut in. 3 years ASP exp. and now doing .DOT which is a step in the wrong direction. Basically I am left with the code of a guy who has left. When I click a button on a pop-up window the javascript for that button click does a 'button.form.submit'. On the Server side there is a Button click event for this button, but for some reason it no longer fires. It worked fine before and everything...
5
1388
by: Coleen | last post by:
Hi all :-) We are using a DB2 database connection through a class module to get the data into a datagrid in an aspx web page using VB.Net. I can get the data into the first datagrid with no problem, however, since I need to do a bunch of calculations with these values AND pull values for two session variable within the web application, I need to create another datagrid to display the calculations. Here is what I'm doing: ...
0
4024
by: Wyatt70 | last post by:
I'm attempting to implement a javascript popup calendar in a DataGrid. The calendar will be used to insert a date into a textbox. I keep getting a "System.NullReferenceException: Object reference not set to an instance of an object" error, which points to the following line: lnkCalendar.Attributes("OnClick") = String.Format("window.open('Calendar.aspx?textbox={0}','cal','...')", txtEstimatedDeploy) Here is the complete code for the...
7
3230
by: julian.tklim | last post by:
Hi, I need to build an editable Datagrid with add & delete buttons on each row using javascript. DataGrid need not be pre-populated with values. To make the thing complicated, one of the column need to be a date picker field. I know things will be easier with ASPX datagrid.
5
1916
by: Peter Afonin | last post by:
Hello, I'm not an expert in Javascript, so I'm seeking an advice. As I mentioned in my previous post, I use Javascript to check whether at least one checkbox in the datagrid has been checked. I have to use Stringbuilder to do this: Dim iCount As Int32 Dim sClientSideValidate As New StringBuilder
0
9714
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10090
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9173
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7635
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6863
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5531
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4308
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3832
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.