Getting ID from asp.net runat server in jQuery

后端 未结 7 2248
执笔经年
执笔经年 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:50

    <%= txtTest.ClientID %> should work but not in a separate javascript file where server side scripts do not execute. Another possibility is to use a class selector:

    <input runat="server" id="txtTest" value="test" class="txtTest" />
    

    and then:

    var value = $('.txtTest').val();
    
    0 讨论(0)
提交回复
热议问题