user211805
user211805

Reputation:

ASP.NET AJAX pageLoad() with multiple Updatepanels

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

Upvotes: 1

Views: 1351

Answers (2)

InfinitiesLoop
InfinitiesLoop

Reputation: 14619

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.

Upvotes: 1

Ralph Lavelle
Ralph Lavelle

Reputation: 5769

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.

Upvotes: 1

Related Questions