Critical Developers

Programmers Knowledge Base

jQuery script not working inside updatepanel

Solved : jQuery not working inside update panel

Eg:- As Usual Call of Script

<script type="text/javascript">
     $(document).ready(function() {
     $(function() {
     $('#gallery1 a').lightBox();   //jquery lightbox is taken as example

The jQuery script wont work after partial postback i.e our ajax request. If you try to call any jQuery script inside an updatepanel, script will not work after the first ajax request. To resolve it, call the jquery script again  as written here :-

Eg:- When you are using update panel call it again like as follow

<script type="text/javascript">
function pageLoad(sender, args) {
if (args.get_isPartialLoad()) {  
$('#gallery1 a').lightBox();   //jquery lightbox is taken as example  


Call your script again on page_load event (either individual aspx page or MasterPage if using)

protected void Page_Load(object sender, EventArgs e)
        ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "mykey", "$(document).ready(function() { $('#gallery1 a').lightBox(); });", true);


pageLoad is executed after every postback, synchronous or asynchronous. pageLoad is a inbuilt function name in ASP.NET AJAX act as handler to the Sys.Application.load event (e.g. Sys.Application.add_load(handler)).

$(document).ready() on the other hand, is executed only once, when the DOM is initially ready/loaded.

Comments (21) -

  • abhay

    08-05-2012 18:46:29 |

    Add after Script Manager its working...

    <script type="text/javascript">
            function EndRequest(sender, args) {

  • Rajesh

    30-08-2012 10:23:42 |

    Thanks. Its Help me .

  • pasaks

    07-11-2012 17:13:43 |

    great..I was wondering in finding the solution.And this Post really was so fruitful. Thanks a lot.

  • Mongoose Bike

    05-02-2015 02:20:04 |

    On a completely unrelated note, where do you host your website? It loads so much faster than mine!

  • Kelly Leyton

    07-02-2015 21:50:59 |

    You've the best infos.

  • Chantay Rais

    07-02-2015 22:38:10 |

    Many thanks extremely helpful. Will share website with my friends.

  • Kristal Mccraven

    08-02-2015 05:17:51 |

    Good evening! Wonderful blog! I am an online coach. I have to offer to you free to read book about how to earn easy 100$ per day from your blogging. LINK:

  • Tuyet Mallak

    09-02-2015 00:22:53 |

    Great looking web site. Think you did a bunch of your very own coding.

  • Chad Edgeman

    09-02-2015 05:17:36 |

    Wonderful page, Preserve the excellent work. Appreciate it.

  • Ulysses Halward

    09-02-2015 12:45:21 |

    Sustain the incredible work !! Lovin' it!

  • Jerome Brison

    09-02-2015 16:58:39 |

    You've got fantastic thing in this article.

  • Verda Barndt

    10-02-2015 15:15:59 |

    Wow cuz this is great work! Congrats and keep it up.

  • Gino Crnich

    10-02-2015 20:30:54 |

    Love the site-- extremely individual friendly and great deals to see!

  • Kiyoko Aceuedo

    11-02-2015 05:31:07 |

    Wow because this is great work! Congrats and keep it up.

  • Sina Pfeiffer

    11-02-2015 14:10:57 |

    Maintain the excellent work and producing in the crowd!

  • Shea Sedlak

    12-02-2015 14:11:34 |

    Wow, gorgeous portal. Thnx ...

  • Lewis Benanti

    12-02-2015 20:17:21 |

    Just wished to state Now i am glad I happened in your site!

  • Jefferson Drainville

    13-02-2015 00:26:30 |

    Great web website! It looks extremely expert! Maintain the excellent work!

  • Sylvester Callies

    13-02-2015 05:20:21 |

    Quite enlightening....look ahead to coming back again.

  • Cruz Schneidmiller

    13-02-2015 15:59:27 |

    Love the website-- very user friendly and whole lots to see!

Comments are closed