Form

The Html.Awe.Form helper will make forms of a certain class defined by
.FormClass(string)
to be posted via ajax, form submission can also be prevented with a confirm dialog by setting
.Confirm(bool)
. A js function can be set to handle the result from the server using
.Success(string)
. Ajax post can be disabled by using
.UseAjax(false)

Basic Usage

@using (Html.BeginForm("AskName", "FormDemo", FormMethod.Post, new { @class = "ajaxForm" }))
{
   ...
}
<div id="result" style="color:green;"></div>
@Html.Awe().Form()
        .FormClass("ajaxForm")
        .Confirm(true)
        .ConfirmOptions(o => { o.YesText = "Yes, do it !"; o.Message = "really post the form ?"; })// change default options
        .Success("showResult")// js func to be called after successful post
        .FillFormOnContent(true)

<script type="text/javascript">
    function showResult(o) {
        $('#result').html('server says your name is ' + o.Name);
    }
</script>

Properties

FormClass(string)
Specify the html class of the forms to apply the Form on
Confirm(bool)
If true form submission will be prevented by a confirm dialog
UseAjax(bool)
When true form submission is made via AJAX (default true)
Success(string)
Set the name of the JavaScript function to be executed on success, the JSON object returned by the server will be passed to this function as an argument
FillFormOnContent(bool)
When true, when the post result will be content (Content(),View(), string, not Json object) the content of the form will be filled with that result
Url(string)
Specify an url that will override the form's action attribute



Comments
By accessing this site, you agree to store cookies on your device and disclose information in accordance with our cookie policy and privacy policy .