Theme: Popup:

Form used to post form via ajax and pass result to Success js function

First Name:
Last Name :

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)
    <% using (Html.BeginForm("AskName", "FormDemo", FormMethod.Post, new { @class = "ajaxForm" }))
{ %>
<%:Html.Partial("AskName") %>
<%} %>

<div id="result" style="color:green;">
</div>
<br/>
<%: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>


Form used to post form via ajax and replace the content of the form with the result

Say something:
    <% using (Html.BeginForm("FillForm", "FormDemo", FormMethod.Post, new { @class = "c2" }))
{%>
<%:Html.Action("FillForm") %>
<%} %>

<%:Html.Awe().Form()
.FormClass("c2")
.FillFormOnContent(true) /* when true and the result is Content/View, the result will be used to fill the form's content*/
.BeforeSubmit("validate")
%>

<script type="text/javascript">
function validate() {
if (!$('#SaySomething').val()) {
alert('please write something in the textbox');
return false;
}
return true;
}
</script>

Used to confirm a form post, and post the form without ajax

    <% using (Html.BeginForm("Index", "FormDemo", FormMethod.Post, new { @class = "normalPost" }))
{%>
<input type="text" name="word" value="click the button"/><input type="submit" value="Submit" class="awe-btn"/>
<%} %>
<%:Html.Awe().Form()
.UseAjax(false)
.Confirm(true)
.FormClass("normalPost")
.Tag(new {target = "confirmCont"})%>
<div id="confirmCont"></div> <%--used for the inline popup--%>