Is it ok to place controls inside UpdatePanel when using jQuery?

daltyPlailm

New Member
With this jQuery code, I am attempting to select the text inside the control, when clicked.\[code\]<html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title> <script src="http://stackoverflow.com/questions/12646247/Scripts/jquery-1.4.1.js" type="text/javascript"></script> <script type="text/javascript"> jQuery(document).ready( function () { jQuery("input[type='text']").click(function () { this.select(); }); }); </script></head><body> <form id="form1" runat="server"> <div> <asp:TextBox Text="Text 1" ID="txt1" ClientIDMode="Static" runat="server" /> <asp:Button Text="Submit" ID="btn1" OnClick="btn1_Click" runat="server" /> <asp:TextBox Text="Text 2" ID="txt2" ClientIDMode="Static" Visible="false" runat="server" /> </div> </form></body></html>\[/code\]Code Behind:\[code\]protected void btn1_Click(object sender, EventArgs e) { txt2.Visible = true; }\[/code\]The issue is when I put contents of the page inside UpdatePanel, jQuery works on first time on txt1. On button click it doesn't work for any of the textboxes.\[code\] <asp:UpdatePanel runat="server"> <ContentTemplate> <asp:TextBox Text="Text 1" ID="txt1" ClientIDMode="Static" runat="server" /> <asp:Button Text="Submit" ID="btn1" OnClick="btn1_Click" runat="server" /> <asp:TextBox Text="Text 2" ID="txt2" ClientIDMode="Static" Visible="false" runat="server" /></ContentTemplate> </asp:UpdatePanel>\[/code\]While debugging using Chrome console I found jQuery is not defined - strange :-( Can you please suggest what could be issue.Thank you for your time.
 
Back
Top