Showing posts with label updatepanel. Show all posts
Showing posts with label updatepanel. Show all posts

Tuesday, May 7, 2013

Jquery Tab does not work in ASP UpdatePanel

I have been using Jquery Tabs a lot lately and they usually work just fine. An issue here and there. Today I had an issue when trying to put the tabs inside an ASP Update Panel. The code did not seem to work. I found this easy fix buried in some forum....so I thought I would put it in my blog to be more accessible...and it worked really...
  1. <script type="text/javascript">
  2. function pageLoad(sender, args) {
  3. if (args.get_isPartialLoad()) {
  4. //put any javascript code
  5. $('#myTabs').tabs();
  6. }
  7. }
  8. </script>

Monday, October 10, 2011

ClientScript.RegisterStartupScript Not Working?

ClientScript.RegisterStartupScript is used to call javascript in the .net code-behind. Once you learn this nice little trick, you think it is great, until one day years later on another page/project you try it again, but it does not work.

First, please check if the control/page you are trying to update contains an UpdatePanel. If so, keep reading.

This WON'T work with an UpdatePanel (in my experience). You will need to use: ScriptManager.RegisterStartupScript

For example:
ScriptManager.RegisterStartupScript(this, this.GetType(), "saving", "doneSaving();", true);

Also, in VS, it did not seem to recognize ScriptManager, when I right-clicked to "Resolve" it gave me no options. I am not sure why but I had to add "using System.Web.UI;" to my using clauses manually. Maybe that was some quirk with my page though...