Javascript and asp.net datagrid controls

T

tshad

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

I want to do something like:
*********************************************************
function CheckQuestion()
{
var checkBox = document.getElementById('_ctl0_SecurityStandard');
if (checkBox.checked)
{
dropDown = document.getElementById('_ctl0_SecretQuestion');
dropDown.disabled = false;
textBox = document.getElementById('_ctl0_SecretQuestionText');
textBox.value = "";
textBox.disabled = true;
}
else
{
dropDown = document.getElementById('_ctl0_SecretQuestion');
dropDown.disabled = true;
textBox = document.getElementById('_ctl0_SecretQuestionText');
textBox.disabled = false;
}
}
***************************************************************

The actual names are SecurityStandard, not _ct10_SecurityStandard.

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

But in a Datagrid I get something like:

<input id="JobBoardsGrid__ctl2_JobBoard" type="checkbox"
name="JobBoardsGrid:_ctl2:JobBoard" onclick="Javascript:CheckQuestion();" />

and the next row will be:

<input id="JobBoardsGrid__ctl3_JobBoard" type="checkbox"
name="JobBoardsGrid:_ctl3:JobBoard" onclick="Javascript:CheckQuestion();" />

Is there a way to know 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 DataGridItemEventArgs)
if e.Item.ItemType = ListItemType.ITem Or _
e.Item.ItemType = ListItemType.AlternatingItem then
Dim oImageButton as CheckBox = CType(e.Item.FindControl("JobBoard"),
CheckBox)
oImageButton.Attributes.Add ("onClick","Javascript:CheckQuestion();")
end if
end Sub
*******************************************************************************

Thanks,

Tom
 
M

Matt Kruse

tshad said:
But in a Datagrid I get something like:
<input id="JobBoardsGrid__ctl2_JobBoard" type="checkbox"
name="JobBoardsGrid:_ctl2:JobBoard"
onclick="Javascript:CheckQuestion();" />

I would not use technology that auto-generated javascript code in such a
clueless manner.
 
R

Randy Webb

tshad said the following on 7/20/2006 5:55 PM:
Nevermind.

I figured it out.

No you didn't.
....onclick="Javascript"CheckQuestion(this);"

Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
 
T

tshad

Randy Webb said:
tshad said the following on 7/20/2006 5:55 PM:

No you didn't.

Actually, I did. I just typed it in wrong.

oImageButton.Attributes.Add ("onClick","Javascript:CheckJobBoard(this);")

This does work.

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top