For use this plugin with add content (for example - adding comment for anonymous users), you need to create view with form added some content.

This sample view for add comment on articles: (online-demo sample)

   <p>Add comment form:</p>
  
<form method="post" action="">
   @Html.AntiForgeryToken()
  
<input type="hidden" name="recaptcha_form_action" value="AddContent" />
   <input type="hidden" name="FolderName" value="Comment" />
  
<input type="hidden" name="Published" value="true" />
  
<input type="hidden" name="ParentFolder" value="Article" />
  
<input type="hidden" name="ParentUUID" value="@ViewBag.Article.UUID" />
  
<table>
      
<tbody>
          
<tr>
              
<th>
                  
<label for="title">
                       Title:*
</label>
              
</th>
              
<td>
                  
<input type="text" id="title" name="title" data-val-required="Title is required" data-val="true" />
                   @Html.ValidationMessageForInput(
"title")
              
</td>
          
</tr>
          
<tr>
              
<th>
                  
<label for="name">
                       Name:*
</label>
              
</th>
              
<td>
                  
<input type="text" id="Name" name="Name" data-val-required="Name is required" data-val="true" />
                   @Html.ValidationMessageForInput(
"Name")
              
</td>
          
</tr>
          
<tr>
              
<th>
                  
<label for="Body">
                       Message:*
</label>
              
</th>
              
<td>
                  
<textarea id="Body" name="Body" cols="20" rows="10" data-val-required="Message is required" data-val="true"></textarea>
                   @Html.ValidationMessageForInput(
"Body")
              
</td>
          
</tr>
          
<tr>
              
<th>
              
</th>
              
<td>
                  
@if (ViewData["ReCaptchaSuccess"] != null && !(bool)ViewData["ReCaptchaSuccess"])
                   {
                    
<strong style="color: red;">Captcha Validation FAILED!</strong>
                   }
                  
@Html.Raw((string)ViewData["ReCaptchaScript"])
                   <br /><button type="submit">Save</button>
              
</td>
          
</tr>
      
</tbody>
  
</table>
  
</form>

Also you need to add this plugin on your view:

add plugin on view

You can use field "RedirectURL" for redirect user to some page after inserting content:

<input type="hidden" name="RedirectUrl" value='@Url.FrontUrl().PageUrl("Thankyou")'/>

You can use this plugin for insert any content.

ReCaptcha plugin return next values:

  • ViewData["ReCaptchaScript"] - js-script for recaptcha input form
  • ViewData["ReCaptchaSuccess"] - true (if captcha is valid) or false (if captcha is not valid)
  • ViewData["ReCaptchaFormResult] - result of execute plugin: "Content was added"

Last edited Mar 20, 2012 at 4:04 PM by EllaSea, version 3

Comments

No comments yet.