Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing ASP.NET AJAX UpdatePanel with Handlers
    text
    copied!<p>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?</p> <p>Im using session to validate the Image on Captcha to the Num on the input below the image </p> <p>this is the Handler : </p> <pre><code>&lt;%@ WebHandler Language="C#" Class="captcha" %&gt; 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 &lt; 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; } } } </code></pre> <p>I want to refresh the image.. not just doing this : </p> <pre><code> public void postbackear() { string script = string.Format("Sys.WebForms.PageRequestManager.getInstance()._doPostBack('{0}', '');", btnConsulta.ID); ScriptManager.RegisterStartupScript(this.Page, typeof(string), "Refresh", script, true); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload