开发者

Storing ActionLink in model or RouteValueDictionary in model

I wish to store an action link in the model.

Something like

public MvcHtmlString ActionLink_New
{
    get { return Html.ActionLink("new", "Edit", "News", new { Area = "Admin" }, null); }
}

It appears the model needs a webviewpage context.

Failing that, I thought I would store just the route values.

public RouteValueDictionary[] RouteValue_New 
{
    get { return new RouteValueDictionary[] { Area = "Admin" };开发者_如何学编程 }
}

//View
@Html.ActionLink("new", "Edit", "News", Model.RouteValue_New, null)

The Area in the property is red. Is either or both scenario achievable. What do i need to add to get this to work, thanks.


try this

public object RouteValue_New
    {
        get { 
            return new { Area = "Admin" }; 
        }
    }
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜