unobtrusive-ajax

.Net Core 3.0 AJAX POST Body Always Null

倖福魔咒の 提交于 2020-06-16 17:07:40
问题 I've recently converted my project from .Net Framework 4.7 to .Net Core 3.0. I'm having trouble getting my AJAX post to work. Here is what's working in .Net Framework 4.7: View: @using (Ajax.BeginForm("Save", "Controller", new AjaxOptions() { HttpMethod = "Post", OnSuccess = "OnSaveSuccess", OnFailure = "OnFailure" }, new { Model })) { ... Model Code Here } Controller: [HttpPost] public JsonResult Save(Contract contract) Here's what is not working in .Net Core 3.0: View: <form method="post"

Loading different scripts versions depending on IE version

流过昼夜 提交于 2019-12-13 00:49:59
问题 I have an asp.net mvc 4 web application that must be compatible with IE 7 to IE 10 and then depending on the IE used I have problems with some scripts version (jquery, etc.) so under my root scripts folder I have created a new folder called OlderIE. When IE 7 is used I want the scripts in OlderIE folder to be loaded. And when IE > 7 is used, the I want scripts in Scripts root folder to be loaded. So how to do this? Related to this, is it possible to have installed in my asp.net mvc 4 project

Get calling form in OnSuccess

吃可爱长大的小学妹 提交于 2019-12-11 10:15:59
问题 <div class=".parentForm'> @Ajax.BeginForm(... AjaxOptions { OnSuccess = "submitSuccess" }) {...} </div> function postDone(result,two, three) { $('.parentForm').replaceWith(result); } I don't like this because if there are multiple forms from this partial they will all have the same class, and I would rather not come up with some funky scheme where I generate an ID on the server side and have to pass it around to the JS callbacks. With .ajax I can use the this to get the form that submitted

Returning BadRequest in ASP.Net Core MVC to Microsoft jQuery Unobtrusive Ajax post has ModelState undefined

可紊 提交于 2019-12-11 08:26:24
问题 THE PROBLEM I am trying to return service side validation errors from ModelState using BadRequest(ModelState) but when I try to assign the the jQuery ModelState from xhr.responseText I am getting undefined error in javascript. I am using ASP.Net Core 1.0.1 with Microsoft.jQuery.Unobtrusive.Ajax 3.2.3. THE CODE Controller Action public async Task<IActionResult> ApplySanction(SanctionViewModel model) { try { if (ModelState.IsValid) { //update database return RedirectToAction("Details"); } else

Rendering a partial View with Ajax Unobtrusive

别等时光非礼了梦想. 提交于 2019-12-11 00:34:28
问题 I have the following View and Partial View. In the index action method I need the Create to rendered as a Partial View. Based on the answer in this question I tried using Ajax helper methods(I find AJAX and JS so hard for me to comprehend). @model IEnumerable<TEDALS_Ver01.Models.UserRight> @{ ViewBag.Title = "Index"; } <table class="table"> <tr> <th> @Html.DisplayNameFor(model => model.UserName) </th> <th> @Html.DisplayNameFor(model => model.UserCode) </th> <th> @Html.DisplayNameFor(model =>

How to reference Microsoft.JQuery.Unobtrusive.Ajax within my ASP.NET Core MVC project

这一生的挚爱 提交于 2019-12-08 17:43:28
问题 I am trying to use Microsoft.JQuery.Unobtrusive.Ajax . I started by installing the package using NuGet and as expected I am able to see it among my dependencies. My problem is that I cant find a way to reference the script so I can use it within my view. Here I saw that I should add this to my layout: <script src="~/lib/Microsoft.jQuery.Unobtrusive.Ajax/jquery.unobtrusive-ajax.min.js"></script> but that path leads to no file: Here is my controller action: [HttpPost] public IActionResult

Unobtrusive AJAX error: “Uncaught ReferenceError: Sys is not defined”

心不动则不痛 提交于 2019-12-08 15:00:16
问题 Example code: In an MVC 5 project in Visual Studio, I have set up the following controller and views: Controller TestController.cs public class TestController : BaseController { public ActionResult Index() { return View("Index"); } public PartialViewResult MyPartialView1() { return PartialView("PartialView1"); } public PartialViewResult MyPartialView2() { return PartialView("PartialView2"); } } Views Index.cshtml @{ Layout = null; } <!DOCTYPE html> <html> <head> <script src="@Url.Content("~

ASP.NET MVC 4: cannot modify jQuery Unobtrusive Ajax

微笑、不失礼 提交于 2019-12-03 17:11:46
问题 Using ASP.NET MVC 4 and NuGet to manage packages. After upgrading to jQuery 1.9.1 via NuGet , I began getting JavaScript errors regarding the removal of the live() function in jQuery 1.9.x . I hit F5 to run in debugging mode from VS.NET, go to the login page, and get the following: Found this StackOverflow answer: https://stackoverflow.com/a/14512797 and made the 4 changes to ~\Scripts\jquery.unobtrusive-ajax.js . My ~\Scripts\jquery.unobtrusive-ajax.js : $(document).on("click", "a[data-ajax

ASP.NET Core and JQuery unobtrusive AJAX not working

时光毁灭记忆、已成空白 提交于 2019-12-03 12:34:47
问题 If I start a new project in .net 4.5 and hit manage nuget packages, search for ajax, then hit install for ajax unobtrusive. I can then go into my cshtml file and type @Ajax.___ e.g. @Ajax.beginForm If I create a new project with Dot Net Core... I cannot, where instead it gives me the useless error: "The name 'Ajax' does not exist in the current context" I've searched the web, found nothing... Basically I want to make a Form with an Ajax call as you could do in .net Such as: " @using (Ajax

ASP.NET Core and JQuery unobtrusive AJAX not working

拥有回忆 提交于 2019-12-03 03:01:38
If I start a new project in .net 4.5 and hit manage nuget packages, search for ajax, then hit install for ajax unobtrusive. I can then go into my cshtml file and type @Ajax.___ e.g. @Ajax.beginForm If I create a new project with Dot Net Core... I cannot, where instead it gives me the useless error: "The name 'Ajax' does not exist in the current context" I've searched the web, found nothing... Basically I want to make a Form with an Ajax call as you could do in .net Such as: " @using (Ajax.BeginForm("EmployeeMaster", "Home", new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "divEmp" })) {