?
Solved

WEIRD! Javascript to get a panels id when in masterpage:  ctl00_ problem

Posted on 2009-05-11
2
Medium Priority
?
327 Views
Last Modified: 2012-05-06
Hi all,
Weird weird one this.
I have a page that has a panel "PopupPanel" that i show and hide with little javascript function.
Since the panel is in a custom control in a content placeholder in a masterpage .. the id of the field changes to:
ctl00_ContentPlaceHolder1_SelectMultipleUsers1_PopupPanel

i.e.
<div id="ctl00_ContentPlaceHolder1_SelectMultipleUsers1_PopupPanel" class="PopupPanel" style="display:none;">

This is pretty annoying but I worked around it by using the created name in the javascript

var theDiv = document.getElementById("ctl00_ContentPlaceHolder1_SelectMultipleUsers1_PopupPanel");

This is all fine until i put it on a different server and for some unknow reason its changed the prefix!! Its now:
_ctl0_ContentPlaceHolder1_SelectMultipleUsers1_PopupPanel

I dont know whats different on that server but the server admin has told me they should be the same! I was never 100% happy using the full name but ah well.

So my question is:
Is there any way to specify what prefix is used with master pages / controls?

Failing that would anyone know of a better way to get the panel in javascript?
Thanks in advance
O
0
Comment
Question by:osion
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 15

Accepted Solution

by:
mohan_sekar earned 2000 total points
ID: 24355472
Your controlname.ClientID in your javascript instead of hardcoding the control name

example: document.getElementById("<%=PopupPanel.ClientID%>")
0
 

Author Closing Comment

by:osion
ID: 31580176
wow! that was fast! thanks a million.. saved ages of time fiddling around with that!
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question