Captcha Mvc [Split markup and script generation]
CaptchaMvc supports the ability to split scripts and markup. When call any extension method to create captcha it returns an object of type ICaptcha, here are the the interface:
/// <summary> /// Represents the captcha model. /// </summary> public interface ICaptcha : IHtmlString { /// <summary> /// Gets the <see cref="IBuildInfoModel"/>. /// </summary> IBuildInfoModel BuildInfo { get; } /// <summary> /// Renders only captcha markup, if any. /// </summary> /// <returns> /// An instance of <see cref="IHtmlString" />. /// </returns> IHtmlString RenderMarkup(); /// <summary> /// Renders only captcha scripts, if any. /// </summary> /// <returns> /// An instance of <see cref="IHtmlString" />. /// </returns> IHtmlString RenderScript(); }
@using CaptchaMvc.HtmlHelpers @using CaptchaMvc.Interface @{ ViewBag.Title = "SplitMarkupAndScript"; ICaptcha captcha = Html.MathCaptcha("Refresh", "Input", "Is required field.", true); } @section Scripts { @captcha.RenderScript() } <h2>The captcha render with Html.MathCaptcha("Refresh", "Input", "Is required field.", true)</h2> @using (Html.BeginForm()) { @captcha.RenderMarkup() <br /> <input type="submit" value="Send"/> }
This is exactly what I needed. Although I'm 100% sure this works in partial views yet. Still testing.
Thanks.