Where does ASP.Net get its rendered IDs from?
        Posted  
        
            by NeilD
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by NeilD
        
        
        
        Published on 2010-04-15T11:10:31Z
        Indexed on 
            2010/04/15
            11:13 UTC
        
        
        Read the original article
        Hit count: 269
        
Hi,
I've inherited a project with some nasty JavaScript that depends on hard coded object ids.
i.e. There are lots of places where it does things like this 
var magazine = document.getElementById('repModuleDisplay__ctl3_chkCats_0');
When the page renders in my UAT environment, the HTML looks like this, and everything works OK.
<input id="repModuleDisplay__ctl3_chkCats_0" 
    type="checkbox" name="repModuleDisplay:_ctl3:chkCats:0"  
    ... etc
However, when I put it on my Production environment, the HTML is suddenly rending like this:
<input id="repModuleDisplay_ctl03_chkCats_0" 
    type="checkbox" name="repModuleDisplay$ctl03$chkCats$0" 
    ... etc
The difference in ids means that the JavaScript can't find the Element, and fails.
In an ideal world, I'd scrap the buggy JavaScript and do it again properly, but for a quick fix, I'd like to know what is causing the difference in rendering between the two environments.
Does anyone have any ideas?
Thanks, Neil
© Stack Overflow or respective owner