jquery not working on server controls in content page
i am having a TextBox txt on a content page. when i try this
$(function(){
$("#txt").focus(function(){alert("abcd"); });
});
i开发者_开发百科t doesn't work. It's working if i am using it on simple .aspx page with no master page.
View the HTML source. I think the most likely problem is the renaming of the controls by prepending the content section's id. You can change this with the ClientIDMode property:
<asp:TextBox ID="txt" runat="server" ClientIDMode="static"/>
if "#txt"
is an <asp:textbox />
control it will get a client id when the page gets rendered, to select an asp.net control you'll need to do $("[id*='txt']")
精彩评论