|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Security.Permissions;
[assembly: WebResource("AbstractAjaxControl.Resources.AjaxBase.js", "text/javascript")]
namespace AjaxControls
{
[AspNetHostingPermission(SecurityAction.Demand, Level=AspNetHostingPermissionLevel.Minimal)]
public abstract class AjaxControl : WebControl
{
private string _scope = null;
public AjaxControl()
{
AjaxRequest += new AjaxRequestEventHandler(HandleAjaxRequest);
}
public string Scope
{
get { return _scope; }
set { _scope = value; }
}
protected override void OnInit(EventArgs e)
{
if (!Page.IsPostBack && Page.Request.Form["scope"] == _scope)
{
OnAjaxRequest();
}
base.OnInit(e);
Page.ClientScript.RegisterClientScriptResource(typeof(AjaxControl), "AbstractAjaxControl.Resources.AjaxBase.js");
}
protected abstract void HandleAjaxRequest(object sender, AjaxRequestEventArgs e);
protected abstract override void RenderContents(HtmlTextWriter output);
private delegate void AjaxRequestEventHandler(object sender, AjaxRequestEventArgs e);
private event AjaxRequestEventHandler AjaxRequest;
private void OnAjaxRequest()
{
if (AjaxRequest != null)
AjaxRequest(this, new AjaxRequestEventArgs(Page.Request.Form));
}
}
}
|
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.