简体   繁体   English

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

[英]success message on redirected page asp .net mvc

here i am going to redirect , and i want show some massage on new page which is open when it redirect , how i show this massage 在这里我要重定向,我想在新页面上显示一些按摩,当它重定向时打开,我如何显示这个按摩

i am on Editinv.cshtml page and after click on submit button it will be redirect to Detail.Cshtml page and ther i want to show success massage 我在Editinv.cshtml页面上,单击“提交”按钮后,它将重定向到Detail.Cshtml页面,因此我想显示成功消息

my redirect code jsonResul 我的重定向代码jsonResul

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

and this is pust method 这是pust方法

$.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;

            }
        });

please help me . 请帮我 。

You can add message to query string by changing to 您可以通过更改为添加消息到查询字符串

redirectUrl = Url.Action("Details", "Perchus", new {id = id, message = "Edited Success"})

redirectUrl will be /Perchus/Details/1?message=Edited Success redirectUrl将是/Perchus/Details/1?message=Edited Success

and in your Detail.Cshtml add code to display message 并在您的Detail.Cshtml中添加代码以显示消息

<p>@Request["message"]</p>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM