i'm using mvc patte in asp.net - c#. In my application I use jquery.blockUI to block user interface while the page is loading. First, I implement this in forms, like this:
wait.js:
$('#form').on("submit", function(){
$.blockUI({message:null});
});
View:
@using (Html.BeginForm("Create","Caterings", FormMethod.Post, new { @id = "form"})) { ....
Now i'm trying implement similar solution but using simple @Html.ActionLink and i can't get it. I used javascript with ajax but i think ajax isn't for this purpose, because my objective is redirect all the page to another view.
in actionlink I use:
<li>@Html.ActionLink("Costos Unitarios", "Edit", "CostosFijosUnitarios", new { @onClick= "RedirigirPantalla('Edit','CostosFijosUnitarios')" })</li>
and js:
function RedirigirPantalla(accion, controler) {
alert("accion: " + accion + " y controller: " + controler);
$.ajax({
contentType: 'application/html; charset=utf-8',
type: 'GET',
beforeSend: function () {
$.blockUI({ message: null });
},
complete: function (actionResult) {
$.unblockUI({ message: null });
document.location.href = actionResult;
},
dataType: 'html',
url: '@Url.Action("action", "controller", null)'.replace("action",accion).replace("controller",controler),
success: (function (actionResult) {
alert("Success " + actionResult.toString());
}),
error: (function (actionResult) {
alert("ERROR " + actionResult.toString());
})
});
}
With this code I can call the controller successfully, but I don't know what to do with ActionResult that it retus.
Any ideas??
Thanks!!
