Search code examples
c#asp.netvisual-studio-community

How do i prevent visual studio from renaming my id attributes?


I have recently migrated to visual studio 2015 community and my JavaScript no longer works because visual studio 2015 renames id attributes based on their content placeholders for example GridView1 will become ContentPlaceholder1_ContentPlaceHolder2_GridView1 at runtime.

How do I turn this off, am using c# and asp.Net ?


Solution

  • You can set the ClientIDMode to Static, f.e. via page directive:

    <%@ Control Language="C#"  ClientIDMode="Static" AutoEventWireup="true" CodeBehind="PageName.ascx.cs" Inherits="WepAppName.PageName" EnableViewState="false" %>