document.getElementById in asp.net with Master Pages

Using JavaScript to locate controls in ASP.net pages that are linked to master pages can be tricky.  This is because the ASP.net reassigns control IDs dynamically and the names change.

A simple solution is to use asp.net inline Tags.

For Example:

Instead for using:

document.getElementById(“Label1″)

try using:

document.getElementById(“<%=Label1.ClientID%>”)

Scroll to top
Join Waitlist We will inform you when the product arrives in stock. Please leave your valid email address below.