Sunday, August 18, 2013

Captcha in Asp.Net

Add   Asp.net Folder  ---  >  Bin
Paste two files ---- >  MSCaptcha.xml   and    MSCaptcha.dll  into  folder Bin
Add a control  Captch to ToolBox--- > ( right button on toolbox---> ChooseItems --- >browse --- > select MSCaptcha.dll   from folder Bin ( new control CaptchaControl will add to ToolBox and use that Control)).

Modify your web.config file, by adding this line to
<httpHandlers>
<add verb="GET" path="CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha"/>
</ httpHandlers>



protected void btnSave_Click(object sender, EventArgs e)
    {
      
       ccJoin.ValidateCaptcha(txtCode.Text); // here check captcha control
      
         if (!ccJoin.UserValidated)
         {
             lblmsg.Text = "Invalid Captcha";
             lblmsg.ForeColor = System.Drawing.Color.Red;
         }
         else
         {
             string insert = "insert into tbl_userreg(fname,uname,password)values('"+txtfname.Text+"','"+txtuname.Text+"','"+txtpwd.Text+"')";
             obj.execute_Query(insert);
             lblmsg.Text = "Datat Entered Successfully";
             lblmsg.ForeColor = System.Drawing.Color.Green;
         }
    }



No comments:

Post a Comment