Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Eran Meir 401 posts 543 karma points
    Feb 09, 2011 @ 22:17
    Eran Meir
    0

    how can i use it?

    can you explain how to use it ?

    i want to add it to a form.

  • Ove Andersen 435 posts 1536 karma points c-trib
    Mar 08, 2011 @ 10:28
    Ove Andersen
    0

    Just add the included usercontrol in your form.

    The form will then only validate if you enter the correct text.

  • Chris Knowles 141 posts 222 karma points
    Apr 19, 2011 @ 15:54
    Chris Knowles
    0

    Ove,

    I have a form in an ascx already and want to add the recaptcha to it, how would be the best way of doing that?

    Thanks

    Chris

  • Ove Andersen 435 posts 1536 karma points c-trib
    Apr 20, 2011 @ 10:23
    Ove Andersen
    0

    Inside your asx, add the following:

     

    <%@ Register TagPrefix="recaptcha" Namespace="Recaptcha" %>
    <recaptcha:RecaptchaControl ID="MyId" Theme="Red" PrivateKey="" PublicKey=""></recaptcha:RecaptchaControl>

    Move the recaptchacontrol to where you want it in your form.

    If you want to use the settings you entered in the Developer section, you have to do the following in codebehind:
    (You alse need to add the datatype to the document type for the page which the form is rendered on)

    var src = Node.GetCurrent();
    var propertyAlias = "The name of the document type property";
    var recaptcha = new RecaptchaControl(); if (umbracoNode != null && umbracoNode.Id != 0)
    {
    // Set Values
    var d = new Document(umbracoNode.Id);
    if (d.getProperty(propertyAlias) != null)
    {
    var pt = d.getProperty(propertyAlias).PropertyType;
    var prevalues = PreValues.GetPreValues(pt.DataTypeDefinition.Id); // Configure control
    recaptcha.ID = "recaptcha_" + pt.DataTypeDefinition.Id;
    recaptcha.Theme = string.IsNullOrEmpty(((PreValue)prevalues[0]).Value) ? "red" : ((PreValue)prevalues[0]).Value;
    recaptcha.PrivateKey = string.IsNullOrEmpty(((PreValue)prevalues[1]).Value)
    ? string.Empty
    : ((PreValue)prevalues[1]).Value;
    recaptcha.PublicKey = string.IsNullOrEmpty(((PreValue)prevalues[2]).Value)
    ? string.Empty
    : ((PreValue)prevalues[2]).Value;
    recaptcha.CustomThemeWidget = string.IsNullOrEmpty(((PreValue)prevalues[3]).Value)
    ? string.Empty
    : ((PreValue)prevalues[3]).Value;
    recaptcha.CustomTranslations = string.IsNullOrEmpty(((PreValue)prevalues[4]).Value)
    ? string.Empty
    : ((PreValue)prevalues[4]).Value;
    }
    }
    // You should change "this" below to a div inside your form this.Controls.Add(recaptcha);

     

     

  • Gordon Saxby 1325 posts 1575 karma points
    Sep 22, 2011 @ 16:24
    Gordon Saxby
    0

    I am trying to do a similar thing but can't get it to work yet.

    I installed the package, then I added the @Register and recaptcha:RecaptchaControl lines from above to my ascx and filled in the public and private keys ... that didn't work.

    Do I have to use the code-behind code as well? Do I have to add a datatype to a document?

  • Ove Andersen 435 posts 1536 karma points c-trib
    Sep 22, 2011 @ 17:16
    Ove Andersen
    0

    Try adding Assembly="Recaptcha" to the @Register tag and see if it works then.

  • Gordon Saxby 1325 posts 1575 karma points
    Sep 23, 2011 @ 12:43
    Gordon Saxby
    0

    OK, I now have the Captcha showing, in my form, but it doesn't stop the form from being submitted ... what else am I missing?

     Do I NEED to do any of the above "code behind" stuff?

     

  • Ove Andersen 435 posts 1536 karma points c-trib
    Sep 23, 2011 @ 12:58
    Ove Andersen
    0

    It depends. Can you post the template code? It will be easier to give a good answer. (Be sure to not post you private key)

  • Gordon Saxby 1325 posts 1575 karma points
    Sep 23, 2011 @ 13:29
    Gordon Saxby
    0

    OK, I have sorted that problem (helps to check page is valid!!) but now it appears to have an image missing, underneath the help (?) icon. There is the following img tag

    <img class="externalLink" alt="external link" src="/static/img/external.gif">

    If I remove it with Firebug the layout of the Captcha tool looks fine.

    Any ideas on that one?!


  • Ove Andersen 435 posts 1536 karma points c-trib
    Sep 23, 2011 @ 16:35
    Ove Andersen
    0

    Try replacing the recaptcha.dll in your bin folder with this one: http://recaptcha.googlecode.com/files/recaptcha-dotnet-1.0.5.0-binary.zip 

  • Gordon Saxby 1325 posts 1575 karma points
    Sep 23, 2011 @ 16:41
    Gordon Saxby
    0

    Err, I now get an error (it mentions Mvc?) -

    Unable to load one or more of the types in assembly 'Recaptcha, Version=1.0.5.0, Culture=neutral, PublicKeyToken=9afc4d65b28c38c2'. Exceptions were thrown:
    System.IO.FileNotFoundException: Could not load file or assembly 'System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
      at umbraco.BusinessLogic.Utils.TypeFinder.FindClassesMarkedWithAttribute(Assembly assembly, Type attribute)
      at umbraco.BusinessLogic.Utils.TypeFinder.FindClassesMarkedWithAttribute(Type attribute)
      at umbraco.macro.GetXsltExtensionsImpl()
      at umbraco.macro.<GetXsltExtensions>b__4()
      at umbraco.cms.businesslogic.cache.Cache.GetCacheItem[TT](String cacheKey, Object syncLock, CacheItemPriority priority, CacheItemRemovedCallback refreshAction, CacheDependency cacheDependency, TimeSpan timeout, GetCacheItemDelegate`1 getCacheItem)
      at umbraco.macro.GetXsltExtensions()
      at umbraco.macro.AddMacroXsltExtensions()
      at umbraco.macro.GetXsltTransformResult(XmlDocument macroXML, XslCompiledTransform xslt, Dictionary`2 parameters)
      at umbraco.macro.loadMacroXSLT(macro macro, MacroModel model, Hashtable pageElements)

     

     

     

  • Gordon Saxby 1325 posts 1575 karma points
    Sep 23, 2011 @ 16:51
    Gordon Saxby
    0

    OK, panic over ... I've found the culprit ... our CSS guy! (was adding an image to all "external" links).

Please Sign in or register to post replies

Write your reply to:

Draft