具有多个 Updatepanels 的 ASP.NET AJAX pageLoad()
您好,
我正在与一些正在开发带有更新面板的应用程序的人合作。
我想在文本字段上使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
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.
如果没有代码示例,很难准确了解您在做什么,但我想到一件事:您是否确保您的 UpdatePanel 仅在需要时更新,如
UpdateMode
参数设置的那样?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?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.