ajax.beginform

@Html.ValidationSummary() does not work within Ajax.BeginForm

╄→尐↘猪︶ㄣ 提交于 2019-12-07 04:51:28
问题 Is there any problem using @Html.ValidationSummary() inside an Ajax.BeginForm form? I have the following scenario and I can't get validation for required fields. The form is just posted and no error is thrown either. This is the View: @using (Ajax.BeginForm("Register", "Account", new AjaxOptions { HttpMethod = "POST", OnSuccess = "closeDialog('RegistroUsuario')" })) { @Html.ValidationSummary() <fieldset> <legend>Cadastro novo Usuário</legend> <table id="changePassword"> <tr> <td class=

Ajax.BeginForm(), OnSuccess - get event target

与世无争的帅哥 提交于 2019-12-07 04:39:49
问题 I can't get the the target of the element which fired OnSuccess() method within Ajax.BeginForm() . So here is the code snippet: @using (Ajax.BeginForm("InsertModel", "Home", new AjaxOptions { HttpMethod = "POST", OnSuccess = "doWork(this,'SomeCustomText')" })) { <div id="container"> <--Some HTML--!> <input type="submit" value="OK"/> </div> } <script> function doWork(e,customText) { alert(customText); //It shows 'SomeCustomText', so its good. alert(e); //[Object] object alert(e.prop("tagName")

MVC5 Ajax.BeginForm refresh whole page

时光怂恿深爱的人放手 提交于 2019-12-06 11:03:25
Why is the form post not happening via ajax but instead is reloading to the new page? My .js includes: <script src="/App/JavaScript/Libraries/jquery-1.11.1-min.js"></script> <script src="/App/JavaScript/Libraries/jquery.validate.js"></script> <script src="/App/JavaScript/Libraries/jquery.validate.unobtrusive.js"></script> My razor view: <div id="login-partial-update"> @using (Ajax.BeginForm("Login",null, new AjaxOptions { UpdateTargetId = "login-partial-update", HttpMethod = "POST" }, new { id = "js-form-login" })) { @Html.TextBoxFor(x => x.Email, new {placeholder = "Email address"}) <div

MVC Ajax.BeginForm Replace strange behaviour

て烟熏妆下的殇ゞ 提交于 2019-12-06 00:09:40
问题 In a partial view, I am using MVCs Ajax.Beginform like followed: <div id="divToReplace"> @using (Ajax.BeginForm("Action", "Controller, new AjaxOptions { InsertionMode = System.Web.Mvc.Ajax.InsertionMode.Replace, UpdateTargetId = "divToReplace" }, new { id = "formID" })) { ... </div> When submitting the form, I would expect that the hole div "divToReplace" is replaced by the answer (the partial view again). But instead the inner html of the div "divToReplace" is replaced by the answer, so the

@Html.ValidationSummary() does not work within Ajax.BeginForm

时光怂恿深爱的人放手 提交于 2019-12-05 10:30:29
Is there any problem using @Html.ValidationSummary() inside an Ajax.BeginForm form? I have the following scenario and I can't get validation for required fields. The form is just posted and no error is thrown either. This is the View: @using (Ajax.BeginForm("Register", "Account", new AjaxOptions { HttpMethod = "POST", OnSuccess = "closeDialog('RegistroUsuario')" })) { @Html.ValidationSummary() <fieldset> <legend>Cadastro novo Usuário</legend> <table id="changePassword"> <tr> <td class="smallField">Username:</td> <td>@Html.TextBoxFor(m => m.UserName)</td> </tr> <tr> <td>Password:</td> <td>@Html

Asp.Net MVC Ajax.BeginForm is not submitting via Ajax

心不动则不痛 提交于 2019-12-04 08:25:19
问题 I've got my form as follows <div id="contact-form" class="hidden" title="Online Request Form"> @Using (Ajax.BeginForm("Contact", "Main", Nothing, New AjaxOptions With {.UpdateTargetId = "status", .HttpMethod = "post"}, New With {.id = "contactUs"})) @<div> @Html.LabelFor(Function(m) m.Name)<br /> @Html.TextBoxFor(Function(m) m.Name)<br /> @Html.LabelFor(Function(m) m.Phone)<br /> @Html.TextBoxFor(Function(m) m.Phone)<br /> @Html.LabelFor(Function(m) m.Email)<br /> @Html.TextBoxFor(Function(m)

MVC Ajax.BeginForm Replace strange behaviour

与世无争的帅哥 提交于 2019-12-04 05:02:01
In a partial view, I am using MVCs Ajax.Beginform like followed: <div id="divToReplace"> @using (Ajax.BeginForm("Action", "Controller, new AjaxOptions { InsertionMode = System.Web.Mvc.Ajax.InsertionMode.Replace, UpdateTargetId = "divToReplace" }, new { id = "formID" })) { ... </div> When submitting the form, I would expect that the hole div "divToReplace" is replaced by the answer (the partial view again). But instead the inner html of the div "divToReplace" is replaced by the answer, so the beginning of the partial view looks like this: <div id="divToReplace"> <div id="divToReplace"> ... What

Ajax.BeginForm - Displaying Validation Errors

杀马特。学长 韩版系。学妹 提交于 2019-12-03 17:50:16
问题 Using the MVC project template in VS2008 (out of the box) I noticed the following: Here is how the Register.aspx form is specified. <% using (Html.BeginForm()) { %> Selecting the Register button without supplying any account info shows this. Account creation was unsuccessful. Please correct the errors and try again. • You must specify a username. • You must specify an email address. • You must specify a password of 6 or more characters. I changed the Register.aspx form to this. <% using (Ajax

Ajax.BeginForm - Displaying Validation Errors

假如想象 提交于 2019-12-03 06:36:20
Using the MVC project template in VS2008 (out of the box) I noticed the following: Here is how the Register.aspx form is specified. <% using (Html.BeginForm()) { %> Selecting the Register button without supplying any account info shows this. Account creation was unsuccessful. Please correct the errors and try again. • You must specify a username. • You must specify an email address. • You must specify a password of 6 or more characters. I changed the Register.aspx form to this. <% using (Ajax.BeginForm("Register", new AjaxOptions { HttpMethod = "Post" })) { %> Selecting the Register button

Asp.Net MVC Ajax.BeginForm is not submitting via Ajax

蹲街弑〆低调 提交于 2019-12-02 23:14:25
I've got my form as follows <div id="contact-form" class="hidden" title="Online Request Form"> @Using (Ajax.BeginForm("Contact", "Main", Nothing, New AjaxOptions With {.UpdateTargetId = "status", .HttpMethod = "post"}, New With {.id = "contactUs"})) @<div> @Html.LabelFor(Function(m) m.Name)<br /> @Html.TextBoxFor(Function(m) m.Name)<br /> @Html.LabelFor(Function(m) m.Phone)<br /> @Html.TextBoxFor(Function(m) m.Phone)<br /> @Html.LabelFor(Function(m) m.Email)<br /> @Html.TextBoxFor(Function(m) m.Email)<br /> @Html.LabelFor(Function(m) m.Question)<br /> @Html.TextAreaFor(Function(m) m.Question)