jQuery doesn't work inside of UpdatePanelhttp://forums.asp.net/t/1687095.aspx/1?jQuery+doesn+t+work+inside+of+UpdatePanelWed, 25 Apr 2012 08:04:06 -040016870954447202http://forums.asp.net/p/1687095/4447202.aspx/1?jQuery+doesn+t+work+inside+of+UpdatePaneljQuery doesn't work inside of UpdatePanel <p>Hey guyz I wonder if somebody else faced this issue.</p> <p>I have user control, which contains TextBox control and some jQuery that avoids user to input anything else but numbers. Here is my user control</p> <pre class="prettyprint">&lt;script type=&quot;text/javascript&quot;&gt; $(&quot;input[type=text][id*=txtBox1]&quot;).live('keydown', function (event) { if ((!event.shiftKey &amp;&amp; !event.ctrlKey &amp;&amp; !event.altKey) &amp;&amp; ((event.keyCode &gt;= 48 &amp;&amp; event.keyCode &lt;= 57) || (event.keyCode &gt;= 96 &amp;&amp; event.keyCode &lt;= 105))) // 0-9 or numpad 0-9, disallow shift, ctrl, and alt { // check textbox value now and tab over if necessary } else if (event.keyCode != 8 &amp;&amp; event.keyCode != 46 &amp;&amp; event.keyCode != 37 &amp;&amp; event.keyCode != 39) // not esc, del, left or right { event.preventDefault(); } }); &lt;/script&gt; &lt;asp:TextBox ID=&quot;txtBox1&quot; MaxLength=&quot;9&quot; CssClass=&quot;allInp&quot; runat=&quot;server&quot;&gt;&lt;/asp:TextBox&gt;</pre> <p>Now I'm dynamically adding this control to Repeater control, which is inside of UpdatePanel. But the problem is jQuery doesn't work once it's inside of UpdatePanel, I tried to get Repeater control outside of UpdatePanel and it worked as expected. Any considerations regardin to this issue?<br> Any kind of help would be appreciated.&nbsp;</p> <p></p> 2011-06-06T13:01:10-04:004447225http://forums.asp.net/p/1687095/4447225.aspx/1?Re+jQuery+doesn+t+work+inside+of+UpdatePanelRe: jQuery doesn't work inside of UpdatePanel <p>Have you tried with the client Id rather than passing the static textbox id?</p> <p>AFAIK, content of the update panel replace after update. You need to rebind the event to the control after the page_load. Use PageRequestManager to declare the javascript event. A little bit of google/bing search will help you a lot.</p> <p>Hope that will help you</p> 2011-06-06T13:14:55-04:004447248http://forums.asp.net/p/1687095/4447248.aspx/1?Re+jQuery+doesn+t+work+inside+of+UpdatePanelRe: jQuery doesn't work inside of UpdatePanel <p>Hello Manvel i tried your code in my sample application and it worked perfectly.... i think there is some issue when your controls renders inside the page then control.clientid is changing thats the reason its not binding to&nbsp;the textbox.....</p> <p>so look in that direction your control inside usercontrol and you are adding that&nbsp;control inside repeater control so you can think what will be id of your control....</p> <p>regards,</p> 2011-06-06T13:35:09-04:004447253http://forums.asp.net/p/1687095/4447253.aspx/1?Re+jQuery+doesn+t+work+inside+of+UpdatePanelRe: jQuery doesn't work inside of UpdatePanel <p>Thanx for quick response.</p> <p>Yeah I've tried with clientId , and checked, it generates right ID of control.</p> <pre class="prettyprint">$(&quot;#&lt;%=txtBox1.ClientID %&gt;&quot;).live('keydown', function (event) { // content });</pre> <p>However it seems doesn't run the script. I've put alert inside of &lt;script&gt; tag, but even alert doesn't showed</p> <pre class="prettyprint">&#36;( function () { alert('hi'); &#36;("#&lt;%=txtBox1.ClientID %&gt;").live('keydown', function (event) { // content }); });</pre> <p>So I don't think the only problem is event doesn't get binded with my control, seems &lt;script&gt; tag is ignored. Am I gettin anywhere closer ?</p> 2011-06-06T13:38:23-04:004447281http://forums.asp.net/p/1687095/4447281.aspx/1?Re+jQuery+doesn+t+work+inside+of+UpdatePanelRe: jQuery doesn't work inside of UpdatePanel <p>Thanx for response Rick!</p> <p>I had similar issue before, and binding events to controls using live() solved my problems, this time it doesn't help, &nbsp;and I get your point Rick, but when I'm lookin @ page source, I can see that both, ID of my control and jQuery selector are same,,, so I don't think that's a problem, also I can't figure out why alert() inside of &lt;script&gt; tag doesn't work, seems when controls rendered &lt;script&gt; tag is ignored, I thought that it may be problem in my jQuery code ( maybe some syntax error ) but it works outside of UpdatePanel. Any other considerations guyz?</p> 2011-06-06T13:51:53-04:004447412http://forums.asp.net/p/1687095/4447412.aspx/1?Re+jQuery+doesn+t+work+inside+of+UpdatePanelRe: jQuery doesn't work inside of UpdatePanel <p>inline script (&lt;script&gt;...&lt;/script&gt;) inside an update panel is only supported on the initial render. any script is ignored on an ajax update. you must use scriptmanger to register the javascript.</p> 2011-06-06T15:47:54-04:004447587http://forums.asp.net/p/1687095/4447587.aspx/1?Re+jQuery+doesn+t+work+inside+of+UpdatePanelRe: jQuery doesn't work inside of UpdatePanel <p>Thanx for response bruce, one question thou. How can I make sure, that registered script from server side would be inserted inside of UpdatePanel's Content, cuz as I understand on partial postbacks only those parts inside of ContentTemplate gets rendered, and refreshed, so if &lt;script&gt; would be inserted anywhere outside of &lt;ContentTemplate&gt; it wouldn't be parsed. If I'm wrong, plz let me know. And once again thanx for response!!!</p> 2011-06-06T18:09:34-04:004447976http://forums.asp.net/p/1687095/4447976.aspx/1?Re+jQuery+doesn+t+work+inside+of+UpdatePanelRe: jQuery doesn't work inside of UpdatePanel <p>Hi,</p> <p>Check this code. I think you are facing this issue-</p> <p><a href="../../../../p/1667058/4359465.aspx/1?Re&#43;Modal&#43;Dialog&#43;not&#43;triggered&#43;by&#43;control&#43;within&#43;update&#43;panel">http://forums.asp.net/p/1667058/4359465.aspx/1?Re&#43;Modal&#43;Dialog&#43;not&#43;triggered&#43;by&#43;control&#43;within&#43;update&#43;panel</a></p> 2011-06-07T03:51:39-04:004448143http://forums.asp.net/p/1687095/4448143.aspx/1?Re+jQuery+doesn+t+work+inside+of+UpdatePanelRe: jQuery doesn't work inside of UpdatePanel <p>Thnax to all of you guys for response, I had to put this into every page that should run this script</p> <pre class="prettyprint">&lt;script type=&quot;text/javascript&quot;&gt; $(document).ready(function () { Sys.WebForms.PageRequestManager.getInstance().add_endRequest(bindKeyDown); bindKeyDown(); }); function bindKeyDown() { $('.numerable').live('keydown', function () { if ((!event.shiftKey &amp;&amp; !event.ctrlKey &amp;&amp; !event.altKey) &amp;&amp; ((event.keyCode &gt;= 48 &amp;&amp; event.keyCode &lt;= 57) || (event.keyCode &gt;= 96 &amp;&amp; event.keyCode &lt;= 105))) { // check textbox value now and tab over if necessary } else if (event.keyCode != 8 &amp;&amp; event.keyCode != 46 &amp;&amp; event.keyCode != 37 &amp;&amp; event.keyCode != 39) { event.preventDefault(); } }); } &lt;/script&gt;</pre> 2011-06-07T06:12:15-04:004950170http://forums.asp.net/p/1687095/4950170.aspx/1?Re+jQuery+doesn+t+work+inside+of+UpdatePanelRe: jQuery doesn't work inside of UpdatePanel <p>hi every one <br> plz check my thread<br> i think that i deal same issue but i can't solve till now<br> <br> <br> http://forums.asp.net/t/1795551.aspx/1?i&#43;think&#43;it&#43;conflict&#43;between&#43;ajax&#43;and&#43;jquery&#43;but&#43;i&#43;m&#43;not&#43;sure<br> <br> thnx</p> 2012-04-25T08:04:06-04:00