views:

400

answers:

2

Greetings,

I'm working with some guys who are developing an app with Update Panels.

I'd like to use the jQuery datepicker on a textfield that is part of a row that can be added multiple times via this update panel, and I've got the JavaScript below to work successfully:

function pageLoad(sender, args)
{
  if(args.get_isPartialLoad())
  {
      $(".datepicker").datepicker({ //rebind to all step datepickers
      duration: ''
      });
  }
}

However, there are multiple update panels on this page so it's being trigged when they all update - is there a way to add a parameter or similar so this only fired when that specific event is needed?

Thanks, Chris

+1  A: 

It's hard to see exactly what you're doing without code examples, but one thing springs to mind: are you making sure that your UpdatePanels are only updating when they need to, as set by the UpdateMode parameter?

<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">

The UpdateMode defaults to always, which means that if there are many UpdatePanels on a page, they will all update if any one of them gets updated, which isn't usually what you want.

Rafe Lavelle
+1  A: 

PageRequestManager's pageLoaded event has more information. The args has a get_panelsUpdated and get_panelsCreated (for nested update panels) property. You could use that to determine which UpdatePanels have updated. You could probably just pass the update panel'd div itself into the jquery selector to filter to only elements within it.

InfinitiesLoop
thanks to you both!
Chris

related questions