重定向页面asp .net mvc上的成功消息

时间:2019-03-14 08:57:54

标签: javascript jquery asp.net-mvc

在这里,我要重定向,我想在重定向时打开的新页面上显示一些消息, 我如何展示这种按摩

我在Editinv.cshtml页面上,单击“提交”按钮后,它将重定向到Detail.Cshtml页面,然后我要显示成功提示

我的重定向代码jsonResul

 return Json(new
        {
            redirectUrl = Url.Action("Details", "Perchus" ,new { id }),
            isRedirect = true
        });

这是除尘方法

$.post(url, { Id: mid, PerTranCode: mtran, Srno: msr, ProductId: mProductId, PGstRate: mPGstRate, PerchesQty: mPerchesQty, PerchesRate: mPerchesRate, GstTax_Amount: mGstTax_Amount, Total: mTotal, ProductName: mProductName, ProductGstCode: mProductGstCode, PreCode: PreCode }, function (json) {
            //mtran: mtran, msr: msr, mProductId: mProductId, mPGstRate: mPGstRate, mPerchesQty: mPerchesQty, mPerchesRate: mPerchesRate, mGstTax_Amount: mGstTax_Amount, mTotal: mTotal, mProductName; mProductName
            if (json.isRedirect) {
                window.location.href = json.redirectUrl;

            }
        });

请帮助我。

1 个答案:

答案 0 :(得分:0)

您可以通过更改为

将消息添加到查询字符串
redirectUrl = Url.Action("Details", "Perchus", new {id = id, message = "Edited Success"})

redirectUrl将为/Perchus/Details/1?message=Edited Success

,然后在您的Detail.Cshtml中添加代码以显示消息

<p>@Request["message"]</p>
相关问题