MVC

1. How to redirect to another controller in MVC using Jquery
    $("#btnSaveCreate").click(function () {
        var data = [];
        var grid = $("#ContactGrid").data("kendoGrid");
        grid.select().each(function () {
            var dataItem = grid.dataItem($(this));
            data.push(dataItem);
        });
        var portalRegRequestId = @Html.Raw(Json.Encode(@ViewBag.portalRegRequestId));
        var URL = "/NewContactAccount/Index?fromProtal=fales&ajax=true&ContactName=" + data[0].ContactName + "&Phone=" + data[0].Phone + "&Email=" + data[0].Email + "&portalRegRequestId=" + portalRegRequestId;
        $.ajax({
            url: URL,
            type: "GET",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (result) {
                debugger;
                window.location.href = "/NewContactAccount/Index?fromProtal=true&ajax=false&ContactName=" + data[0].ContactName + "&Phone=" + data[0].Phone + "&Email=" + data[0].Email + "&portalRegRequestId=" + portalRegRequestId;
            }
        });
    });



2. Return Json


 return Json(result, JsonRequestBehavior.AllowGet);




3. Redirect to another controller with parameters

return RedirectToAction("TeamGetPortalRegistration", "AdminList", new { portalRegRequestId = model.portalRegRequestId });

No comments:

Post a Comment