Rad captcha validating By code.

3 posts, 0 answers
  1. Deepak
    Deepak avatar
    9 posts
    Member since:
    Aug 2010

    Posted 06 Jan 2011 Link to this post

    Hi guys,
    I am using rad captcha in my site and want to prevent the user if
    user type the wrong captcha test . So for this i am validate the captcha by coding.
    But i am facing the problem that captcha always give Return false in if(radcaptcha1.isvalid) and print error.
    Here my code of Default.aspx
    <asp:Label ID="lblCaptcha" runat="server" ForeColor="Red"></asp:Label>
                               <telerik:RadCaptcha ID="RadCaptcha1" runat="server" validationgroup="Submit">
     <asp:UpdatePanel runat="server" ID="UPbtnUpload" >
                                 <asp:ImageButton runat="server" ID="btnUpload" CssClass="btnAdd" ImageUrl="~/Images/btnUpload.jpg"
                                    OnClick="btnUpload_OnClick" ValidationGroup="Submit" />
                                <asp:PostBackTrigger ControlID="btnUpload" />
    And the code of default.aspx.cs is
    protected void btnUpload_OnClick(object sender, EventArgs e)
               if (RadCaptcha1.IsValid)
                   testimonial.ClubName = txtClub.Text;
                   testimonial.Desciption = txtDiscription.Text;
                   if (imageFileUpload.UploadedFiles.Count > 0)
                       Guid guid = new Guid();
                       testimonial.FileName = imageFileUpload.UploadedFiles[0].FileName;
                       testimonial.FilePhysicalPath = imageFileUpload.TargetFolder;
                       testimonial.FileUrl = imageFileUpload.TargetFolder + imageFileUpload.UploadedFiles[0].FileName;
                   bool isCreated = KiwanisDataServices.CreateTestimonial(testimonial, ddlState.SelectedValue.ToString());
                   lblCaptcha.Enabled = true;
                   lblCaptcha.Text = "The code you entered is not valid";
                   //RadCaptcha1.ErrorMessage = "deepak";
      Plz help me out for this problem there is any general solution of this.
    I am structed with this problem plz telrik help me ya give me some example by this i can  accomplish it.
  2. Deepak
    Deepak avatar
    9 posts
    Member since:
    Aug 2010

    Posted 07 Jan 2011 Link to this post

    i did not understand why rad captcha not validate properly always return false by 
               if (Page.IsValid && RadCaptcha1.IsValid)
    Plz help me asps.
  3. Pero
    Pero avatar
    1156 posts

    Posted 11 Jan 2011 Link to this post

    Hi Deepak,

    You should place the RadCaptcha in the UpdatePanel, as I think the problem is caused by an ajax request executed before the Captcha control is validated.
    The RadCaptcha control updates its code on every trip to the server, regardless if it is a full postback or Ajax postback. In case of the Ajax postback the code will not be shown on the CaptchaImage if the control is not affected by the ajax call. So, the Captcha should be placed inside an UpdatePanel.

    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Back to Top