Master Pages and Javascript Issues

Master Pages and JAVASCRIPT:
We ran into an issue today with Master pages and found a solution for this problem.
If you are used to the ASP.NET 1.1 way of refering controls(using ID) in Javascript and if you are using Masterpages, then you will be surprised to see that its not working.
With Master pages, it generates an ID at the runtime and if you refering the ID attribute. ASP.NET makes sure each control ID is unique by prefixing every control ID with its parents control ID’s. Hence you will get the JAVASCRIPT Error.
Trick here is to refer using the clientID attribute…
Example: document.getElementById("<%=dtControl1.ClientID %>")
Check this article for more details

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s