I am using .NET 4 with ClientIDMode="Static" which outputs controls with nice clean id's, although the "name" is still messy when nested in master pages, user controls, etc...
For example:
<input type="text" id="txtEmail" name="ctl00$hdr$txtEmail" />
However, when I tried to use the id as I expected to set something like:
"...validate({ rules|messages: {
txtEmail: "required" }..." it wasn't working.
But if I change it to use name instead like :
"...rules|messages: {
ctl00$hdr$txtEmail: "required" }..." it will work.
Unfortunately this is a problem in .NET 4.
The benefit of using static id's in .NET 4 is not only for clean id's for client script, but also because the generated munged id's of v1-3.5 and now generated munged names in v4.0 can change at any time if you rename a parent control/master page etc.. that the child control is contained within, or even nest it deeper.
This means the messy munged name will break if hardcoded in javascript.
Is there any way we can use id instead of name for setting the rules/messages properties? Or is there just a different syntax I'm missing.
Thanks!