+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / How to add Captcha in Custom Sitefinity Form Builder?

How to add Captcha in Custom Sitefinity Form Builder?

10 posts, 0 answered
  1. Saroj Rout
    Saroj Rout avatar
    31 posts
    Registered:
    14 Apr 2011
    07 Mar 2013
    Link to this post

    Hello Team:

    I have Custom form builder, i want to include captcha control in the form builder. i found one link from this url "http://www.sitefinity.com/blogs/radoslav-georgievs-blog/2011/12/14/captcha_for_sitefinity_forms" regarding how to add captcha.

    i want download that captcha project, but i am not getting where is the link to download captcha form control.

     

    Please give the url to download captcha project, so that i will include that project to my custom form builder.

     

    Thanks in advance!!!!!!

    Saroj Rout

  2. Patrick Dunn
    Patrick Dunn avatar
    237 posts
    Registered:
    03 Nov 2014
    12 Mar 2013
    Link to this post
    Hello Saroj,

     Thanks for using Sitefinity.

    The captcha form project is in the SDK under samples. You can download the SDK from here.

    I hope this helps.

    Greetings,
    Patrick Dunn
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Saroj Rout
    Saroj Rout avatar
    31 posts
    Registered:
    14 Apr 2011
    12 Mar 2013 in reply to Patrick Dunn
    Link to this post

    Hi

    i have downloaded the SDK and installed but didn't get any Captcha project in the sample folder. Please send me the exact link to download or give me a zip file of the captcha project if you have.

     

    Thanks in advanced

  4. Markus
    Markus avatar
    2763 posts
    Registered:
    25 Nov 2005
    12 Mar 2013 in reply to Saroj Rout
    Link to this post

    Dear Patrick

    Still think Chaptcha support for forms build should come out of the box.

    Saroj vote here: http://www.telerik.com/support/pits.aspx#/details/Issue=10655 already 43 votes. So Telerik this is a requeste feature!

    Markus

  5. Mark
    Mark avatar
    147 posts
    Registered:
    01 Jun 2010
    25 Jul 2013
    Link to this post
    Does anyone know where the captcha project went? It's no longer in the SDK.
  6. Stefani Tacheva
    Stefani Tacheva avatar
    718 posts
    Registered:
    06 Dec 2016
    31 Jul 2013
    Link to this post
    Hello Mark,

    The project is not removed from the Sitefinity SDK. Check the Akismet(http://akismet.com/) integration sample available there.

    Regards,
    Stefani Tacheva
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    31 Jul 2013 in reply to Stefani Tacheva
    Link to this post
    I'm embedding this into my randomsitecontrols on next release...but...

    1) Add captcha to your forms toolbox, just edit your toolboxconfig and add this node (on the same level as the others)
    <toolbox name="FormControls">
        <sections>
            <add name="Common">
                <tools>
                    <add enabled="True" type="Telerik.Web.UI.RadCaptcha, Telerik.Web.UI" title="RadCaptcha" description="RadCaptcha" visibilityMode="None" name="RadCaptcha" />
                </tools>
            </add>
        </sections>
    </toolbox>
    Now when you edit a form, the captcha will be available for drag\drop and you can edit and set properties on it (like skin\etc).

    2) Drop this code into your site...it just inherits from the default form to look for a valid captcha before save...so just enhances the default control, it's not really that "custom"
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Linq;
    using System.Net;
    using System.Net.Mail;
    using System.Text;
    using System.Text.RegularExpressions;
    using Telerik.Microsoft.Practices.EnterpriseLibrary.Logging;
    using Telerik.Sitefinity.Configuration;
    using Telerik.Sitefinity.Modules.Forms;
    using Telerik.Sitefinity.Modules.Forms.Web.UI;
    using Telerik.Sitefinity.Modules.Forms.Web.UI.Fields;
    using Telerik.Sitefinity.Services;
    using Telerik.Sitefinity.Web.UI;
    using Telerik.Sitefinity.Web.UI.Fields;
    using Telerik.Web.UI;
     
    namespace RandomSiteControls.Forms {
        /// <summary>
        /// Add the captcha control to your toolbox like this
        ///     <toolbox name="FormControls">
        ///         <sections>
        ///             <add name="Common">
        ///                 <tools>
        ///                     <add enabled="True" type="Telerik.Web.UI.RadCaptcha, Telerik.Web.UI" title="RadCaptcha" description="RadCaptcha" visibilityMode="None" name="RadCaptcha" />
        ///                 </tools>
        ///             </add>
        ///         </sections>
        ///     </toolbox>
        /// </summary>
        public class FormCaptcha : FormsControl
        {
            protected override void InitializeControls(GenericContainer container)
            {
                if (!SystemManager.IsDesignMode)
                {
                    //Hide the form if JS is disabled, it'll let them bypass the required fields.
                    base.InitializeControls(container);
                    this.BeforeFormSave += new EventHandler<CancelEventArgs>(FormsControlCustom_BeforeFormSave);
                }
            }
     
     
            #region EVENTS
            protected void FormsControlCustom_BeforeFormSave(object sender, CancelEventArgs e)
            {
                if (this.MyCaptcha != null)
                {
                    if (!this.MyCaptcha.IsValid)
                    {
                        e.Cancel = true;
                        this.MyCaptcha.ErrorMessage = this.CaptchaErrorMessage;
                    }
                }
            }
     
            #endregion
     
            #region METHODS
     
            #endregion
     
            #region Properties
            private RadCaptcha _captcha = null;
            protected RadCaptcha MyCaptcha
            {
                get
                {
                    if (!SystemManager.IsDesignMode)
                    {
                        foreach (var control in this.FormControls.Controls[1].Controls)
                        {
                            if (control.GetType() == typeof(RadCaptcha))
                            {
                                _captcha = control as RadCaptcha;
                                break;
                            }
                        }
                    }
     
                    return _captcha;
                }
            }
     
            private string _captchaErrorMessage = "Invalid Code, please try again";
            /// <summary>
            /// This gets edited in advanced mode
            /// </summary>
            public string CaptchaErrorMessage
            {
     
                get
                {
                    return _captchaErrorMessage;
                }
                set
                {
                    _captchaErrorMessage = value;
                }
            }
            #endregion
        }
    }

    3) Edit your toolboxes.config again, find the forms control, and set it's type to be the above type
    <namespace>.<classname>, <assembly>
    Ex: RandomSiteControls.Forms.FormCaptcha, SitefinityWebApp

    Done...and works, just implimented this again on another site last night weirdly enough




  8. Mark
    Mark avatar
    147 posts
    Registered:
    01 Jun 2010
    31 Jul 2013 in reply to Steve
    Link to this post
    The Sitefinity Hero strikes again! Thank you Steve
  9. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    31 Jul 2013 in reply to Steve
    Link to this post
    **JUST KEEP IN MIND**
    If you have a form on an existing page, you'll need to delete the control, and then re-drag it from the toolbox.  Reason being is the one on the page IS the "FormsControl" not my enhanced "FormCaptcha"
  10. Stefani Tacheva
    Stefani Tacheva avatar
    718 posts
    Registered:
    06 Dec 2016
    31 Jul 2013
    Link to this post
    Hello,

    Thank you Steve for sharing a solution.

    Regards,
    Stefani Tacheva
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
10 posts, 0 answered