开发者

The name 'ViewData' does not exist in the current context

开发者 https://www.devze.com 2023-04-12 08:55 出处:网络
I am working over my first application over MVC3 and still kind of a newbie in it: I’m trying to success my ViewData[] over a master page because its contains a message that would be used over every

I am working over my first application over MVC3 and still kind of a newbie in it:

I’m trying to success my ViewData[] over a master page because its contains a message that would be used over every page, but when I’m trying to access that it says:

CS0103: The name 'ViewData' does not exist in the current context

var msg = ViewData["msg"] as string;
        //var msg = ViewBag.msg as string;
        if (msg != null)
        {
            Response.Write (msg);
        } else if (msg == null)
 开发者_如何学C       {
            Response.Write("");
        }

I am not sure whether I’m doing something wrong or it’s just not possible to access ViewData[] over my MasterPage. Help please!


You need to set your master page to inherit System.Web.Mvc.ViewMasterPage.

0

精彩评论

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

关注公众号