SGIC2008
asked on
why do my Control IDs suddenly reference "_ctl0" in ASP.NET?
Hello All,
I have a web application in ASP.NET that uses a master page as a template.
Everything works fine in our development environment, but when we deploy the application to the production environment all of the control IDs change:
For example, this on development:
<input name="ctl00$cphMainContent $txtSomeTe xtbox" type="text" id="ctl00_cphMainContent_t xtSomeText box" />
Becomes this on release:
<input name="_ctl0:cphMainContent :txtSomeTe xtbox" type="text" id="_ctl0_cphMainContent_t xtSomeText box" />
The application uses javascript on numerous pages to access elements via the 'getDocumentById' function, so having the IDs changes in the source like this is buggering things up quite a bit. The server is configured the same for .NET for both environments.
Has anyone else also seen this behavior? What is cause and how do I go about fixing it so that the IDs do not change in the source?
Many thanks,
pvirk
I have a web application in ASP.NET that uses a master page as a template.
Everything works fine in our development environment, but when we deploy the application to the production environment all of the control IDs change:
For example, this on development:
<input name="ctl00$cphMainContent
Becomes this on release:
<input name="_ctl0:cphMainContent
The application uses javascript on numerous pages to access elements via the 'getDocumentById' function, so having the IDs changes in the source like this is buggering things up quite a bit. The server is configured the same for .NET for both environments.
Has anyone else also seen this behavior? What is cause and how do I go about fixing it so that the IDs do not change in the source?
Many thanks,
pvirk
This is "standard" behavior of ASP.Net...
You can use txtSome.ClienID to get the "Server Control ID at RunTime" and you can then pass that info to your JavaScript...
Here's an example of how I use it:
KeywordTB.Attributes.Add(" onKeyPress ", "doClick('" + KwdSrchBtn.ClientID + "')")
You can use txtSome.ClienID to get the "Server Control ID at RunTime" and you can then pass that info to your JavaScript...
Here's an example of how I use it:
KeywordTB.Attributes.Add("
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks this was exactly what the problem was. The root web.config had this set to legacy and this was inherited by our application that was in a sub folder.
HTML Web Controls, however, do not change their ControlID's between edit and published views.