473,386 Members | 1,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Problem with Aps.Net 2.0 Master Page. ID's?

Hello,

I am using a Master Page (MyMaster) with a Content Place Holder
(ID="ContentPlaceHolder1").
In MyPage.aspx I inserted an Asp:Panel (ID="Panel1") inside
ContentPlaceHolder1.

I am having problems using javascript functions with Panel1.
For example, my javascript functions say they can't find an element with
ID="Panel1" in my page.

The same happens when I use CSS styles like "#Panel1 {...}".

I believe the problem is that when MyPage.aspx runs Panel1's ID becomes
"ctl00_ContentPlaceHolder1_Panel1".
I saw the Panel1's ID in IE and Firefox "View Source" option.

How can I solve this so I can use my javascript functions and CSS "#..."
type styles?

Thank You,
Miguel

Mar 15 '06 #1
3 4292
hi miguel ,
i also encountered this issue. as long as you are dealing with
controls that always have the same ID, you can just refer to the full
name "ctl00_ContentPlaceHolder1_Panel1" in your javascript.

or you could add server code to specify the javascript
attributes/values accessing the Control.UniqueID property which should
contain the fully qualified control name.

to overcome the CSS issue, i would use class names instead of IDs.

let me know if this doesn't solve your problem.
tim

Mar 15 '06 #2
Master pages alter the ID's. You can reference them using ClientID,
which gets you the ID as it is rendered on the client.

For CSS you can use CSS classes, they don't get altered. If the CSS is
defined on the page you might be able to inject the ClientID using <%=
Panel1.ClientID %> although I have never tried this.

Mar 15 '06 #3
Hi,

About CSS that was exactly what I did. I am using classes.
But how to get the client id on a javascript function?

Thanks,
Miguel

"Jacob" <ja***@reimers.dk> wrote in message
news:11**********************@j52g2000cwj.googlegr oups.com:
Master pages alter the ID's. You can reference them using ClientID,
which gets you the ID as it is rendered on the client.

For CSS you can use CSS classes, they don't get altered. If the CSS is
defined on the page you might be able to inject the ClientID using <%=
Panel1.ClientID %> although I have never tried this.


Mar 15 '06 #4

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

Similar topics

7
by: Martijn Saly | last post by:
Hi there, I've created a master page with some controls on it, a Calendar control among others. Now depending on the date(s) selected, the content page needs to be updated. In the masterpage...
3
by: Mark Olbert | last post by:
I have some img tags on a master page which reference files in a top-level directory. They look like this: <img src="assets/test.gif" id="gnr" /> assets is a subdirectory of the website root. ...
3
by: ivanpais | last post by:
Hi, I have a Web User Control, Lets say "Foo.ascx", that contains a button "btnFoo". I have a Master Page "Bar.master", that has a label "lblBar". This label is exposed by a public property...
17
by: Rob R. Ainscough | last post by:
Again another simple concept that appears NOT to be intuitive or I'm just stupid. I've read the WROX book and the example doesn't actually show how the .master page links in the other content...
0
by: Sergio E. | last post by:
Hello, I have a problem with masterpages and forms security. I made a new Web site, in which I have my page of login like of beginning, a master page with only a sitemappath object in it, the...
0
by: Sergio E. | last post by:
Hello, I have a problem with masterpages and forms security. I made a new Web site, in which I have my page login.aspx as the homepage , a master page with only a sitemappath object in it, the...
0
by: jediknight | last post by:
I have a simple project where there is a master page called MasterPage.master and some webforms which are content pages. I also have a usercontrol which is a simple calendar control popup. The...
8
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= | last post by:
I the page knows there was a cross post back. but i can not find the control. (asp.net 3.5) calling page has a master calling control: <asp:Button ID="btnSendAlert" runat="server" Text="Go"...
5
by: xlar54 | last post by:
I have a very simple 2.0 website (framework), that uses a master page...not. I added the default.aspx page as a webcontent form, with the master page as it's master page, but the master page is...
2
by: pankajsingh5k | last post by:
Dear All, Please help me... I had read an article to lazy load a tab in a tabcontainer using an update panel on http://mattberseth.com/blog/2007/07/how_to_lazyload_tabpanels_with.html ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...

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.