views:

30

answers:

2

I have a website which is hosted on GoDaddy they have version 4.0 runtime. The issue is the client id of the server controls are generated as "contentPlaceHolder1_drpBanks" where it was earlier (when the website was on some other server) getting generated as "ctl00_contentPlaceHolder1_drpBanks".

What I need to know is there a way to resolve this so that I don't have to make any changes in the code.

Like a setting in web.config file or something.

+1  A: 

Controls in ASP.NET 4.0 have a ClientIDMode property. If you set this to AutoID, ASP.NET should generate client ids in the same way it did in ASP.NET 2.0. Here's an article that explains the different client id modes.

Besides setting ClientIDMode at the control level, you can also set it at the page or application level:

<%@ Page Language="C#" ClientIDMode ="AutoID" ... %>

or

<system.web>
    <pages clientIDMode="AutoID" />
</system.web>

But I agree with leppie's comment that it is dangerous to rely on generated client ids.

Ronald Wildenberg
Sure I will take care next time onwards. Thanks alot
Sandhurst
+2  A: 

In the future use <%=Control.ClientID%> which will successfully resolve every time - without code changes.

m.edmondson