<%@ WebHandler Language="VB" Class="Gallery" %>

Imports System
Imports System.Web
Imports System.Web.UI
Imports System.IO

Public Class Gallery
	Implements IHttpHandler
    
	Public Sub ProcessRequest(ByVal context As HttpContext) Implements System.Web.IHttpHandler.ProcessRequest
		'return rendered gallery table control for ajax request    
        
		context.Response.ContentType = "text/plain"
		context.Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache)
        
		Using pageHolder As New Page()
			Using viewControl As Control = pageHolder.LoadControl("~/AjaxDemo/GalleryTable.ascx")
				Using output As New StringWriter()
					pageHolder.Controls.Add(viewControl)
					HttpContext.Current.Server.Execute(pageHolder, output, False)
					context.Response.Write(output.ToString())
				End Using
			End Using
		End Using
	End Sub
    
	Public ReadOnly Property IsReusable() As Boolean Implements System.Web.IHttpHandler.IsReusable
		Get
			Return False
		End Get
	End Property
    
End Class
