父页面中 UpdatePanel 的用户控件中的 ASP.NET AJAX UpdateProgress
我正在开发 ASP.NET Web 表单应用程序。在我的页面中,我有一个 UpdatePanel
和一个带有 UpdateProgress
和一堆按钮的用户控件。当用户单击其中一个按钮时,我想执行异步回发并显示 UpdateProgress
。
任何人都可以帮助我使回发异步(看起来有效)以及使UpdateProgress
出现(尚未起作用) ?
通常,通过在页面标记中定义 UpdateTrigger
可以很容易地完成此操作。在用户控件内部它不是。我公开了一个公共属性 AssociatedUpdatePanelID
,以便在控件内拥有 UpdatePanel
的 ID。
UpdateProgress
定义如下:
<asp:UpdateProgress AssociatedUpdatePanelID='<%# AssociatedUpdatePanelID %>' />
这就是我在控件的 Page_Load
中尝试的方法,但没有一种方法有效(执行回发,但 UpdateProgress
没有出现):
updatePanel.Triggers.Add(new AsyncPostBackTrigger()
{
ControlID = this.ID,
EventName = "RequestOptimize"
});
var scriptMgr = ToolkitScriptManager.GetCurrent(Page);
scriptMgr.RegisterAsyncPostBackControl(optimizeButtonJobs);
scriptMgr.RegisterAsyncPostBackControl(this);
I'm working on an ASP.NET web forms application. In my Page I have an UpdatePanel
and a user control with an UpdateProgress
and a bunch of buttons. When the user clicks one of the buttons, I'd like to perform an asynchronous postback and show the UpdateProgress
.
Can anyone help me with making the postback asynchronous (looks like it works) as well as making the UpdateProgress
appear (doesn't work yet)?
Usually, this can be done pretty easily by defining an UpdateTrigger
in the page markup. Inside the user control it isn't. I exposed a public property AssociatedUpdatePanelID
, to have the UpdatePanel
's ID inside the control.
The UpdateProgress
is defined as follows:
<asp:UpdateProgress AssociatedUpdatePanelID='<%# AssociatedUpdatePanelID %>' />
That's what I tried in my control's Page_Load
, but none of the approaches works (postback is performed, but UpdateProgress
does not appear):
updatePanel.Triggers.Add(new AsyncPostBackTrigger()
{
ControlID = this.ID,
EventName = "RequestOptimize"
});
var scriptMgr = ToolkitScriptManager.GetCurrent(Page);
scriptMgr.RegisterAsyncPostBackControl(optimizeButtonJobs);
scriptMgr.RegisterAsyncPostBackControl(this);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只需在页面上将用户控件注册为异步回发触发器即可。不再需要魔法。它对我不起作用的原因是(意外地)在按钮上设置了 PostBackUrl 属性。
You can just register your user control on the page as an async postback trigger. No more magic required. The reason it didn't work for me was a PostBackUrl property that was (accidentially) set on the button.