Contact Yart for a relaxed conversation
Your Name * Message *
Your Email *  
Your Phone   
Our Phone:        03 8685 8718 (within Australia)
61 3 8685 8718 (outside Australia)
Contact Yart

Melbourne Content Management and Flash developers

 

for designers, agencies and your website

Resources / Programming / Add Yart Captcha to a Web Form
Add Yart Captcha to a Web Form
  1. Copy the aspx code from APP/YartCaptcha which consists of:
    • HiddenField
    • Image
    • TextBox
    • CustomValidator
    • Button
    to your own page in one of the asp TableCell where you want to put your captcha.
  2. Add an attribute ValidationGroup in your button, say ValidationGroup="vbABCForm4"
  3. 3. Copy the code from the same file to the .cs file:

    protected void vldCaptcha_ServerValidate(object source,ServerValidateEventArgs args)
    {
       args.IsValid = m_captcha.Verify(hidCaptcha.Value, tbCaptcha.Text);
    }

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
       if(Page.IsValid)
         Response.Redirect(ABCFunctions.AspxFilenameWithoutExt + "/Thank-you.aspx");
       else
         GenerateCaptcha();
    }

    Server.MapPath(captchaTempDir));
       if (!IsPostBack)
       GenerateCaptcha();
    }

    private void GenerateCaptcha()
    {
       hidCaptcha.Value = m_captcha.CreateImage();
       imgCaptcha.ImageUrl = m_captcha.LastImageUrl;
       tbCaptcha.Text = "";
    }

  4. YartCaptcha m_captcha;

    protected void Page_Load(object sender, EventArgs e)
    {
       string captchaTempDir = AppPath + "admin/temp/";
       m_captcha = new YartCaptcha(125, 50, captchaTempDir,

  5. 4. Move the contents in the Page_Load(object sender, EventArgs e) to your own Page_Load method.
  6. Move the contents in btnSubmit_Click(object sender, EventArgs e) method to your own btn_Click method, and put your code in side your method inside if(Page.IsValid)
The latest at Yart
Search: