473,756 Members | 8,110 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

access web controls in a User control via Javascript

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="ucUntouched Items_spUntouch ed" style="CURSOR:h and;COLOR:#0033 99"
onClick="toggle BB(ucUntouchedI tems_divUntouch ed,
ucUntouchedItem s_imgUntouched, ucUntouchedItem s_htbUntouched) ">
<img id="ucUntouched Items_imgUntouc hed"
src="/TicketSystemV2/images/collapse.gif" border="0"
style="border-style:None;heig ht:16px;width:1 6px;" />
<span id="ucUntouched Items_lbGridNam e">Untouched Items (4)</span><br>
</span>
<input id="ucUntouched Items_htbUntouc hed" type="hidden" />
<div id="ucUntouched Items_divUntouc hed" style="DISPLAY: none">

If I run at the buttom of the page:

<script language=javasc ript>
alert(ucUntouch edItems_htbUnto uched);
alert(ucUntouch edItems_imgUnto uched);
alert(ucUntouch edItems_divUnto uched);
</script>

I get Errors on the first 2.

Any ideas why? I am missing something???

Nov 18 '05 #1
1 1498
You may want to try document.getEle mentByID(...) to get a reference to that
object, and then grab the value attribute of that object. ie:

var htbUntouched = document.getEle mentByID("ucUnt ouchedItems_htb Untouched");
if (htbUntouched != null) {
window.alert(ht bUntouched.valu e);
}

--
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*******@cuar tel15.com> wrote in message
news:O8******** *****@TK2MSFTNG P12.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="ucUntouched Items_spUntouch ed" style="CURSOR:h and;COLOR:#0033 99"
onClick="toggle BB(ucUntouchedI tems_divUntouch ed,
ucUntouchedItem s_imgUntouched, ucUntouchedItem s_htbUntouched) ">
<img id="ucUntouched Items_imgUntouc hed"
src="/TicketSystemV2/images/collapse.gif" border="0"
style="border-style:None;heig ht:16px;width:1 6px;" />
<span id="ucUntouched Items_lbGridNam e">Untouched Items (4)</span><br>
</span>
<input id="ucUntouched Items_htbUntouc hed" type="hidden" />
<div id="ucUntouched Items_divUntouc hed" style="DISPLAY: none">

If I run at the buttom of the page:

<script language=javasc ript>
alert(ucUntouch edItems_htbUnto uched);
alert(ucUntouch edItems_imgUnto uched);
alert(ucUntouch edItems_divUnto uched);
</script>

I get Errors on the first 2.

Any ideas why? I am missing something???


Nov 18 '05 #2

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

Similar topics

2
3024
by: paul meaney | last post by:
All, myself and another developer have been staring blankly at a screen for the past 48 hours and are wondering just what stunningly obvious thing we are missing. We are trying to load up 2 or more user controls dynamically by adding to a placeholder defined in page_load. I've included the sample code for how we are accessing one. The user controls are not rocket science - just a few text boxes with public accessor properties. We've...
2
2155
by: bill | last post by:
I have the following user control in my project simply for setting focus to a control: Public Class SetFocus Inherits System.Web.UI.UserControl
3
7143
by: qwerty | last post by:
I have two User controls in a page. Them ID-propertys are example UC1 and UC2. In code behind file they are declared: Public UC1 As UC1 Public UC1 As UC1 From the page I can call them with their name (UC1 and UC2) and access their public propertys and functions.
1
1115
by: Bennett Haselton | last post by:
I create a new Web Form and drag a new Button onto it from the Web Forms toolbox tab, and then I drag a new instance of the UserPost user control that I created, by dragging and dropping the "UserPost.ascx" file listing from Solution Explorer. Both controls show up on the Web Form. But when I switch to the codebehind page, there is only a declaration for Button1: protected System.Web.UI.WebControls.Button Button1; and not one for...
7
7001
by: Lau Lei Cheong | last post by:
Hello, I'm using javascript's insertAdjacentHtml() to insert images to the webform at runtime. This runs fine(image successfully displayed at the browser) but when I tried to access the control's src using FindControl() function in the code-behind, it seems that the control doesn't even exist. I know that I can add controls on the server-side, but then a postback will be needed which is the thing I want to avoid. Does anyone have idea...
1
2131
by: digitalego | last post by:
Sorry if the title is a little confusing... Here is the problem. I am working with a "default.aspx" page that uses a user control I made: ------------------------------ | default.aspx | ------------------------------ <%@ Page language="C#" CodeBehind="ChartPage.cs"
5
1230
by: shapper | last post by:
Hello, I have been trying to add a user control at runtime to a page: Dim myUserControl As Control = LoadControl("MyUserControl.ascx") The problem is this does not give me access to the user control properties. So I tried the following: Dim myUserControl As MyUserControl =
3
1927
by: Fred Chateau | last post by:
I am trying to access a user control class, for a user control that is loaded dynamically, from the containing page. I have been able to access Web controls in the user control, but so far I have been unable to expose the user control class itself. I'm guessing that I need to set up an interface, but I am not sure how to accomplish this. Here is the code that loads the user control: protected void Page_Init(object sender, EventArgs e)...
3
4189
by: cfps.Christian | last post by:
I'm trying to have a javascript file included with my usercontrol, but when the page loads it says that none of my JS methods are there. What are the steps that I need to take to get a javascript file to go with the user control so that I don't have to load the script onto the page that is calling the control?
1
2159
by: Shraddha | last post by:
Hi, I am adding some ASP.Net user controls (.ascx file) dynamically on the button click. The user control will get added as many times userhits the button. Now on the click of the submit button, I want to do some form level validations. For example suppose my .ascx file contains a text box with id say "trialTextBox". Now if user hits the button thrice, 3 user controls will be there on the page and as a result 3 textboxes mentioned...
0
9456
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
10040
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9873
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9713
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
8713
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
7248
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...
1
3806
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
3359
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.