开发者

asp.net mvc parameter

I 开发者_Python百科want to display a prompt message when he is redirceted from a special page, how can accomplish this? Passing messsage as paramater is not so pretty. a used a booling paramater to determinig situation to display message.


Why not pass the boolean in ViewData (whether to display the message) based upon interrogating Request.ServerVariables["http_referer"] in your controller?

in controller

ViewData["DisplayMessage"] = 
    Request.ServerVariables["http_referer"] == "http://Special.com";

in view

<% if ((bool)ViewData["DisplayMessage"])){ %>
<div>YOUR MESSAGE</div>
<% } %>

Kindness,

Dan

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜