Reputation: 2368
I have a gridview with the following template field
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnLoad" runat="server" Text="Load" CssClass="inptBtn" OnClientClick="return loadPlans(this);" UseSubmitBehavior="false" />
<ItemTemplate>
</asp:TemplateField>
This has run fine for awhile. On the onclick we run some code that checks the Id generated by .NET for this control and does stuff with it. In the past, the Id generated looked like this
gvPlans_ctl02_hdPlans
This is still what is generated in our dev and test environments, but in prod, it now looks like this
gvPlans_hdPlans_0
The code is definitely the same in both environments, but I'm not sure what is causing the naming convention change. I tried to google an answer, but the search terms are a little generic for this problem so I turn to the trusty SO. I assume the answer might have something to do with which framework is running or something similarly simple. Please let me know if you have any idea, thanks!
Upvotes: 4
Views: 1466
Reputation: 340366
This is controlled by the control's ClientIDMode property:
The default for this can be configured in the web.config file:
Or it can be set for a page in the @Page
directive:
Upvotes: 2
Reputation: 108987
You can experiment with ClientIDMode
if you are using .NET4. But in general the generated cliend id should not matter. You should be able to use control.ClientID
in javascript and other places to avoid referencing the generated client-id directly, in which case even if there is a difference in the markup generated b/w test server and production, your code logic should be able to adapt.
Upvotes: 1
Reputation: 31260
Check the application pool for this application and target framework. The target framework seems to be different between prod and dev/text env. Also check the installed frameworks and SPs.
Upvotes: 0