Hi, Im using UpdatePanel for some controls specially for captchas so, when a AsyncPostBack is performed triggered by a button "btnQuery", How can I tell to the .ashx (Handler for Captcha) to refresh it self?
Im using session to validate the Image on Captcha to the Num on the input below the image
this is the Handler :
<%@ WebHandler Language="C#" Class="captcha" %>
using System;
using System.Web;
using System.Web.SessionState;
using System.Drawing;
public class captcha : IHttpHandler, IRequiresSessionState
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "image/GIF";
Bitmap imagen_GIF = new System.Drawing.Bitmap(80, 30);
Graphics grafico = System.Drawing.Graphics.FromImage(imagen_GIF);
grafico.Clear(Color.Gainsboro);
Font tipo_fuente = new Font("Comic Sans", 12, FontStyle.Bold);
string randomNum = string.Empty;
Random autoRand = new Random();
for (int x = 0; x < 5; x++)
{
randomNum += System.Convert.ToInt32(autoRand.Next(0, 9)).ToString();
}
int i_letra = System.Convert.ToInt32(autoRand.Next(65, 90));
string letra = ((char)i_letra).ToString();
randomNum += letra;
context.Session["RandomNumero"] = randomNum;
grafico.DrawString(randomNum, tipo_fuente, Brushes.Black, 5, 5);
imagen_GIF.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);
tipo_fuente.Dispose();
grafico.Dispose();
imagen_GIF.Dispose();
}
public bool IsReusable { get { return false; } }
}
I want to refresh the image.. not just doing this :
public void postbackear()
{
string script = string.Format("Sys.WebForms.PageRequestManager.getInstance()._doPostBack('{0}', '');",
btnConsulta.ID);
ScriptManager.RegisterStartupScript(this.Page, typeof(string), "Refresh", script, true);
}