替代的UpdatePanel上的用户控件(ASCX页)控件、用户、UpdatePanel、ASCX

2023-09-10 20:14:13 作者:冇心

我目前工作的一个ASP.NET AJAX应用程序。在决定不使用的UpdatePanel为明显的原因,有什么替代我?这个应用程序具有动态等内置页大部分或页面的所有组分存在作为用户控制。

I am currently working on a ASP.NET AJAX application. Having decided to not use UpdatePanels for evident reasons, what alternatives to I have? This application has pages built dynamically and so most or all the components of the page exist as User Controls.

我需要从ASCX用户控制网页AJAX调用。而作为ASCX用户控件可能不包含页面方法,做什么其他的选择,我有吗?

I need to make AJAX calls from ASCX user control page. And as ASCX user controls may not contain Page Methods, what other options do I have?

或者,有没有办法在ASCX页使用页面的方法来解决?

Or, is there a way to get around using Page Methods in ASCX page?

推荐答案

最好的方法(我发现)是 1.将PageMethods父页上 2.当PageMethod的完成,让我们通过它可以在PageMethod的呼叫已完成了JS的方法,用户控件知道 3.然后,ICallbackHandler可以对用户的控制来实现做用户控件的方法的AJAX回调

Best way (that I discovered) is to 1. Place your PageMethods on the parent page 2. When the PageMethod completes, let your user control know via a JS method that it can the PageMethod call has been completed 3. Then a ICallbackHandler can be implemented on the user control to do a AJAX callback on the user control's method

在我的情况,我需要得到执行PageMethods后更新用户控制一些值,所以我用HtmlOutputWriter更新内容,建立我的用户控件。

In my case, I need to update some values on the user control after the PageMethods gets executed, so I build my user control using HtmlOutputWriter to update the contents.

对我的作品!