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

access web controls in a User control via Javascript

P: n/a
Hi,
I have a user control that has a series of web controls in it.
I need to access the web controls from the parent page via javascript. No, I
have done this in the past but know I am having problems. It just will not
find the obj on the javascript side.

here is some code (HTML output):
<span id="ucUntouchedItems_spUntouched" style="CURSOR:hand;COLOR:#003399"
onClick="toggleBB(ucUntouchedItems_divUntouched,
ucUntouchedItems_imgUntouched,ucUntouchedItems_htb Untouched)">
<img id="ucUntouchedItems_imgUntouched"
src="/TicketSystemV2/images/collapse.gif" border="0"
style="border-style:None;height:16px;width:16px;" />
<span id="ucUntouchedItems_lbGridName">Untouched Items (4)</span><br>
</span>
<input id="ucUntouchedItems_htbUntouched" type="hidden" />
<div id="ucUntouchedItems_divUntouched" style="DISPLAY:none">

If I run at the buttom of the page:

<script language=javascript>
alert(ucUntouchedItems_htbUntouched);
alert(ucUntouchedItems_imgUntouched);
alert(ucUntouchedItems_divUntouched);
</script>

I get Errors on the first 2.

Any ideas why? I am missing something???

Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
You may want to try document.getElementByID(...) to get a reference to that
object, and then grab the value attribute of that object. ie:

var htbUntouched = document.getElementByID("ucUntouchedItems_htbUntou ched");
if (htbUntouched != null) {
window.alert(htbUntouched.value);
}

--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--

"george d lake" <ge*******@cuartel15.com> wrote in message
news:O8*************@TK2MSFTNGP12.phx.gbl...
Hi,
I have a user control that has a series of web controls in it.
I need to access the web controls from the parent page via javascript. No,
I
have done this in the past but know I am having problems. It just will not
find the obj on the javascript side.

here is some code (HTML output):
<span id="ucUntouchedItems_spUntouched" style="CURSOR:hand;COLOR:#003399"
onClick="toggleBB(ucUntouchedItems_divUntouched,
ucUntouchedItems_imgUntouched,ucUntouchedItems_htb Untouched)">
<img id="ucUntouchedItems_imgUntouched"
src="/TicketSystemV2/images/collapse.gif" border="0"
style="border-style:None;height:16px;width:16px;" />
<span id="ucUntouchedItems_lbGridName">Untouched Items (4)</span><br>
</span>
<input id="ucUntouchedItems_htbUntouched" type="hidden" />
<div id="ucUntouchedItems_divUntouched" style="DISPLAY:none">

If I run at the buttom of the page:

<script language=javascript>
alert(ucUntouchedItems_htbUntouched);
alert(ucUntouchedItems_imgUntouched);
alert(ucUntouchedItems_divUntouched);
</script>

I get Errors on the first 2.

Any ideas why? I am missing something???


Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.