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

Forums / General Discussions / Captcha for Sitefinity 5

Captcha for Sitefinity 5

2 posts, 0 answered
  1. Sergejs
    Sergejs avatar
    1 posts
    Registered:
    13 Feb 2012
    24 Apr 2012
    Link to this post
    Hi
    I was trying to add form Captcha custom control in Sitefinity 5, but there was a problem with path on Path name. For example,

    using

     

     

    System;

    using

     

     

    System.Collections.Generic;

    using

     

     

    System.Linq;

    using

     

     

    System.Text;

    using

     

     

    Telerik.Sitefinity.Web.UI;

    using

     

     

    System.ComponentModel;

    using

     

     

    System.Web.UI;

    using

     

     

    Telerik.Sitefinity.Modules.Pages;

    using

     

     

    System.Web.UI.HtmlControls;

    using

     

     

    Telerik.Pdf.Security;

    using

     

     

    Telerik.Sitefinity.Forms.Model;

    using

     

     

    Telerik.Sitefinity.Modules.Forms;

    using

     

     

    Telerik.Sitefinity.Modules.Forms.Web.UI.Fields;

    using

     

     

    System.Globalization;

    using

     

     

    Telerik.Sitefinity.Fluent;

    namespace

     

     

    Telerik.Sitefinity.SitefinityWebApp

    {

     

    class FormQapTchaControl: SimpleScriptView

    {

    #region

     

     

    Properties

     

    protected override string LayoutTemplateName

    {

     

    get { return null; }

    }

     

    public override string LayoutTemplatePath

    {

     

    get

    {

     

    return this.layoutTemplatePath;

    }

     

    set

    {

     

    this.layoutTemplatePath = value;

    }

    }

    [

     

    Category("QapTcha properites")]

     

    public bool AutoRevert

    {

     

    get

    {

     

    return this.autoRevert;

    }

     

    set

    {

     

    this.autoRevert = value;

    }

    }

    [

     

    Category("QapTcha properites")]

     

    public bool DisabledSubmit

    {

     

    get

    {

     

    return this.disabledSubmit;

    }

     

    set

    {

     

    this.disabledSubmit = value;

    }

    }

    [

     

    Category("QapTcha properites")]

     

    public string TxtLock

    {

     

    get

    {

     

    return this.txtLock;

    }

     

    set

    {

     

    this.txtLock = value;

    }

    }

     

    [

     

    Category("QapTcha properites")]

     

    public string TxtUnlock

    {

     

    get

    {

     

    return this.txtUnlock;

    }

     

    set

    {

     

    this.txtUnlock = value;

    }

    }

    #endregion

    [

     

    Browsable(false)]

     

    public HtmlGenericControl QapTchaDiv

    {

     

    get

    {

     

    return this.Container.GetControl<HtmlGenericControl>("QaptCha", true);

    }

    }

    #region

     

     

    Methods

     

    protected override void OnPreRender(EventArgs e)

    {

     

    base.OnPreRender(e);

     

    PageManager.ConfigureScriptManager(this.Page, ScriptRef.JQueryUI);

    }

     

    public override IEnumerable<System.Web.UI.ScriptDescriptor> GetScriptDescriptors()

    {

     

    var descriptors = new List<ScriptDescriptor>();

     

    var descriptor = new ScriptControlDescriptor(typeof(FormQapTchaControl).FullName, this.ClientID);

     

    //pass

    descriptor.AddProperty(

     

    "qapTchaDiv", this.QapTchaDiv.ClientID);

    descriptor.AddProperty(

     

    "autoRevert", this.AutoRevert);

    descriptor.AddProperty(

     

    "disabledSubmit", this.DisabledSubmit);

    descriptor.AddProperty(

     

    "txtLock", this.TxtLock);

    descriptor.AddProperty(

     

    "txtUnlock", this.TxtUnlock);

    descriptors.Add(descriptor);

     

    return descriptors;

    }

     

    public override IEnumerable<System.Web.UI.ScriptReference> GetScriptReferences()

    {

     

    var scripts = new List<ScriptReference>()

    {

     

    new ScriptReference(FormQapTchaControl.componentScriptPath, typeof(FormQapTchaControl).Assembly.FullName),

     

    new ScriptReference(FormQapTchaControl.qapTchaScript, typeof(FormQapTchaControl).Assembly.FullName),

     

    new ScriptReference(FormQapTchaControl.jqueryUITouchScript, typeof(FormQapTchaControl).Assembly.FullName)

    };

     

    return scripts;

    }

     

    protected override void InitializeControls(GenericContainer container)

    {

    }

    #endregion

    #region

     

     

    Private fields

     

    public string layoutTemplatePath = "~/Samples/SitefinityWebApp.Resources.Views.FormQapTchaControl.ascx";

     

    private bool autoRevert = true;

     

    private bool disabledSubmit = true;

     

    private string txtLock = "Locked : form can't be submited";

     

    private string txtUnlock = "Unlocked : form can be submited";

     

    private static string componentScriptPath = "SitefinityWebApp.Resources.Scripts.FormQapTchaControl.js";

     

    private static string jqueryUITouchScript = "SitefinityWebApp.Resources.Scripts.jquery.ui.touch.js";

     

    private static string qapTchaScript = "SitefinityWebApp.Resources.Scripts.QapTcha.jquery.js";

    #endregion

    }

    }


    After adding this custom control in form, he shows message
    Value cannot be null.
    Parameter name: stream

    Or can be situation that all form elements aren't shown and form isn't active.
    What the problem? It's possible to add Captcha in Sitefinity 5?
  2. MB
    MB avatar
    302 posts
    Registered:
    09 Jan 2005
    24 Apr 2012
    Link to this post
    Check the properties of your resources (template etc) to make sure Build Action == Embedded Resource.

    I'm always forgetting to do that and then get this type of error.
2 posts, 0 answered