How to use JQuery with Master Pages?

后端 未结 13 1152
甜味超标
甜味超标 2020-12-04 18:13

I can get simple examples to work fine as long as there\'s no master page involved. All I want to do is click a button and have it say \"hello world\" with the javascript in

13条回答
  •  爱一瞬间的悲伤
    2020-12-04 18:43

    Reference the the Jquery .js file in the head of the MasterPage as follows:

     
    

    (some browsers don't like ending it with />)

    Then you can write things like

    $('#<%= myBtn.ClientID%>').show() 
    

    in your javascript making sure to use the ClientId when referencing an ASP.Net control in your client code. That will handle any "mangling" of names and ids of the controls.

提交回复
热议问题