How do I access a DIV from javascript, if ASP.NET mangles its ID?
Posted
by Rising Star
on Stack Overflow
See other posts from Stack Overflow
or by Rising Star
Published on 2010-06-15T19:03:57Z
Indexed on
2010/06/15
22:12 UTC
Read the original article
Hit count: 183
I have a web page that contains a "div" element. On the page, there is javascript to reference the div: document.getElementById('divId')
. This was working fine until another developer redesigned the page to use an ASP master page.
Now, document.getElementById('divId')
returns null. It appears that ASP.net prepends some characters to the names of elements within contents forms when you use a master page. How can I know what the id of the div is when the page loads?
Update Allow me to give a specific example to clarify the question: My page had a div with ID divNotice
. After changing my page to use a master page, I see when I print the source to the page that renders that the div ID is ctl00_ContentPlaceHolder1_divNotice
. My question is, how am I supposed to know what the div ID is going to be when the framework is done with it?
© Stack Overflow or respective owner