<%@ WebHandler Language="C#" Class="Gallery" %>

using System;
using System.Web;
using System.Web.UI;
using System.IO;

public class Gallery : IHttpHandler {
    
    public void ProcessRequest (HttpContext context) {
		//return rendered gallery table control for ajax request    
		
		context.Response.ContentType = "text/plain";
		context.Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache);
		
		using (Page pageHolder = new Page())
		using (Control viewControl = pageHolder.LoadControl("~/AjaxDemo/GalleryTable.ascx"))
		using (StringWriter output = new StringWriter())
		{
			pageHolder.Controls.Add(viewControl);
			HttpContext.Current.Server.Execute(pageHolder, output, false);
			context.Response.Write(output.ToString());
		}
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}