|
using System;
using System.Web;
namespace Ajax
{
/// <summary>
/// Includes the CallBack event, Context, Request and Response, for convenience.
/// </summary>
/// <remarks>
/// Inhering from AjaxPage is not required to apply AJAX on your pages. You can
/// implement the ICallBackEventHandler on your page to handle the CallBack event, and
/// use the HttpContext.Current, CallBackHelper.Request and CallBackHelper.Response
/// properties.
///
/// You cannot use the Context, Request and Response of the System.Web.UI.Page
/// because, during a CallBack, the Context of the page is invalid. If you don't want
/// to replace the Page.Request and Page.Response from your code for
/// CallBackHelper.Request and CallBackHelper.Response, and your page is inherited
/// from System.Web.UI.Page, you can use AjaxPage for convenience.
/// </remarks>
public class AjaxPage : System.Web.UI.Page, ICallBackEventHandler
{
/// <summary>
/// Raised by AjaxHttpModule when a CallBack occurs
/// </summary>
public event EventHandler CallBack;
/// <summary>
/// The base Page Request property doesn't work during a CallBack. Use this instead.
/// </summary>
public new HttpRequest Request
{
get
{
return Context.Request;
}
}
/// <summary>
/// The base Page Response property doesn't work during a CallBack. Use this instead.
/// </summary>
public new HttpResponse Response
{
get
{
return Context.Response;
}
}
/// <summary>
/// Raises the CallBack event.
/// </summary>
/// <remarks>
/// Called by AjaxHttpModule.
/// </remarks>
public void RaiseCallBackEvent()
{
OnCallBack (EventArgs.Empty);
}
protected override HttpContext Context
{
get
{
return HttpContext.Current;
}
}
protected virtual void OnCallBack(EventArgs e)
{
if (CallBack != null)
CallBack(this, e);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.