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

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

public class gallery : IHttpHandler
{

	private HttpContext _context;
	private readonly string galleryPath = "../UploadedFiles/";

	public void ProcessRequest(HttpContext context)
	{
		_context = context;

		//return rendered gallery table control for ajax request    

		context.Response.ContentType = "text/plain";
		context.Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache); // Disable browser cache

		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, true);
			context.Response.Write(output.ToString());
		}
	}

	public bool IsReusable
	{
		get
		{
			return false;
		}
	}

}