there is already a ASP.NET server control for this called MScaptcha. its a free control. You can download its dll from the following site
http://www.mondor.org/captcha.aspx[
^]
You will get proper documentation, regarding how to use it.
Still for youe help, belowgiven are brief steps how to implement it.
Download the dll and add its refrence to your project and then do the following.
//Web.config
<httpHandlers>
<add verb="GET" path="CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha"/>
</httpHandlers>
//In Aspx page or in user control
<%@ Register Assembly="MSCaptcha"Namespace="MSCaptcha" TagPrefix="cc1" %>
<cc1:CaptchaControl ID="ccJoin" runat="server" CaptchaBackgroundNoise="none" CaptchaLength="5" CaptchaHeight="60" CaptchaWidth="200" CaptchaLineNoise="None" CaptchaMinTimeout="5" CaptchaMaxTimeout="240" />
///C# Code
Button click event
ccJoin.ValidateCaptcha(txtcaptchatext.Text.Trim());
if (ccJoin.UserValidated)
{
//submit form
}