Saturday, January 13, 2007

getElementById with Master Pages

When using master pages and at certain other times the names of objects on an asp page get mangled to prevent name clashes. This makes it so that any javascript that references these objects is no longer able to find the element by its original name. To work around this use the following syntax with the getElementById


document.getElementById("<%= [ObjectName].ClientID %>")

Change [ObjectName] to be the name of the object you want to find.

No comments:

Post a Comment