具有多个 Updatepanels 的 ASP.NET AJAX pageLoad()

发布于 2024-08-11 09:56:29 字数 415 浏览 2 评论 0原文

您好,

我正在与一些正在开发带有更新面板的应用程序的人合作。

我想在文本字段上使用 jQuery 日期选择器,该文本字段是可以通过此更新面板多次添加的行的一部分,并且我已经让下面的 JavaScript 成功工作:

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

但是,此上有多个更新面板页面,因此当它们全部更新时就会触发 - 有没有办法添加参数或类似参数,以便仅在需要特定事件时触发?

谢谢, 克里斯

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

等待圉鍢 2024-08-18 09:56:29

PageRequestManager 的 pageLoaded 事件有更多信息。 args 具有 get_panelsUpdated 和 get_panelsCreated (用于嵌套更新面板)属性。您可以使用它来确定哪些 UpdatePanel 已更新。您可能只需将更新面板 div 本身传递到 jquery 选择器中即可仅过滤其中的元素。

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.

爱格式化 2024-08-18 09:56:29

如果没有代码示例,很难准确了解您在做什么,但我想到一件事:您是否确保您的 UpdatePanel 仅在需要时更新,如 UpdateMode 参数设置的那样?

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

UpdateMode 默认为always,这意味着如果页面上有很多 UpdatePanel,则只要其中任何一个更新,它们都会更新,但通常情况下不会发生这种情况。你想要的。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文