Storing ActionLink in model or RouteValueDictionary in model
I wish to store an action link in the model.
Something likepublic 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" };
}
}
精彩评论