This project is read-only.

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="CaptchaFormAction" 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>Enter code:
</th>
<td>@Html.Raw((string)ViewData["CaptchaImage"])
                  @Html.Raw((string)ViewData["CaptchaReloadLink"])
@if (ViewData["CaptchaSuccess"] != null && !(bool)ViewData["CaptchaSuccess"])
{
<strong style="color: red;">Captcha Validation FAILED!</strong>
}
                   <input type="text" id="captcha" name="captcha" data-val-required="Code is required" data-val="true" />
                   @Html.ValidationMessageForInput(
"captcha")

<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.

Custom Captcha plugin return next values:

  • ViewData["CaptchaImage"] - image with captcha code (with IMG tag and link for reload)
  • ViewData["CaptchaReloadLink"] - link for reload captcha image (with A tag)
  • ViewData["CaptchaSuccess"] - true (if captcha is valid) or false (if captcha is not valid)
  • ViewData["CaptchaFormResult] - result of execute plugin: "Content was added" or Error Message

Last edited Aug 25, 2012 at 11:35 AM by EllaSea, version 2

Comments

No comments yet.