Getting ID from asp.net runat server in jQuery

后端 未结 7 2279
执笔经年
执笔经年 2020-12-01 17:17

I\'m trying make some stuff in jQuery using ASP.NET. But the ID from runat=\"server\" is not the same as the id used in HTML.

I used to use this to get

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-01 17:43

    When using ASP.NET 4 and the ClientIDMode is set to “Predictable”, you can predict the ID based on hierarchy. Or set it set to “Static”, so asp.net wont mess it up.

    ScottGu's article on it http://weblogs.asp.net/scottgu/archive/2010/03/30/cleaner-html-markup-with-asp-net-4-web-forms-client-ids-vs-2010-and-net-4-0-series.aspx

    And this is extremely useful when using external JS file scenarios.

提交回复
热议问题