ASP.NET AJAX的UpdateProgress用户控制的UpdatePanel父页 [英] ASP.NET AJAX UpdateProgress in User Control for UpdatePanel in parent page

查看:157
本文介绍了ASP.NET AJAX的UpdateProgress用户控制的UpdatePanel父页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个ASP.NET Web窗体应用程序。在我的网页我有一个的UpdatePanel ,并用的UpdateProgress 用户控件和一堆按钮。当用户点击一个按钮,我想执行异步回发并显示的UpdateProgress

谁能帮我的使得回发异步(看起来像它的工作原理),以及制作的UpdateProgress 显示(还没有工作)?

通常,这可以很容易地通过在页面标记定义的 UpdateTrigger 完成pretty。内部用户控件事实并非如此。我露出一个公共属性 AssociatedUpdatePanelID ,有控制在的UpdatePanel 的ID。

的UpdateProgress 定义如下:

 < ASP:的UpdateProgress AssociatedUpdatePanelID ='<%#AssociatedUpdatePanelID%GT;' />

这就是我在我的控制的的Page_Load ,但没有办法工作(执行回发,但的UpdateProgress 不出现):

  updatePanel.Triggers.Add(新AsyncPostBackTrigger()
{
    控件ID = this.ID,
    事件名称=RequestOptimize
});VAR scriptMgr = ToolkitScriptManager.GetCurrent(页);
scriptMgr.RegisterAsyncPostBackControl(optimizeButtonJobs);
scriptMgr.RegisterAsyncPostBackControl(本);


解决方案

您只需注册页作为异步回发触发器在用户控件。无需更多的魔法。它并没有为我工作的原因是,这是一个PostBackUrl属性(accidentially)上的按钮设置。

 < ASP:AsyncPostBackTrigger控件ID =myCustomControl/>

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);

解决方案

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.

<asp:AsyncPostBackTrigger ControlID="myCustomControl" />

这篇关于ASP.NET AJAX的UpdateProgress用户控制的UpdatePanel父页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆