By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,473 Members | 1,267 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,473 IT Pros & Developers. It's quick & easy.

Javascript and asp.net datagrid controls

P: n/a
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

Jul 20 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
tshad wrote:
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.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Jul 20 '06 #2

P: n/a
Nevermind.

I figured it out.

....onclick="Javascript"CheckQuestion(this);"

"Matt Kruse" <ne********@mattkruse.comwrote in message
news:e9********@news4.newsguy.com...
tshad wrote:
>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.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com


Jul 20 '06 #3

P: n/a
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?

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 20 '06 #4

P: n/a
"Randy Webb" <Hi************@aol.comwrote in message
news:GK******************************@comcast.com. ..
tshad said the following on 7/20/2006 5:55 PM:
>Nevermind.

I figured it out.

No you didn't.
Actually, I did. I just typed it in wrong.

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

This does work.

Tom
>....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?

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices -
http://www.JavascriptToolbox.com/bestpractices/

Jul 20 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.