Getting ID from asp.net runat server in jQuery

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

    
    

    and then:

    var value = $('.txtTest').val();
    

提交回复
热议问题