Sunday, September 14, 2008

Captcha for Visual Webgui

I needed a captha for one of my projects I develop using Visual Webgui.
So I found this article on CodeProject regarding simple captcha's. The next step was to create a webgui control derived from PictureBox that implement a IGatewayControl.

In short the important part is implementing GetGatewayHandler interface
IGatewayHandler IGatewayControl.GetGatewayHandler(IContext objContext, string strAction)
{
CaptchaImage img = new CaptchaImage(this.Text, this.Width, this.Height);
img.Image.Save(HttpContext.Current.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
return null;
}


This will show an scrambled image of the controls Text property in the control.
For more information on this article see it on CodeProject here
To download click here
Like this:

Monologue