0
在我的_layout.cshtml我想添加一个像这样的菜单:如何在_layout.cshtml中传递参数actionLink asp.net MVC 3
@Context.User.Identity.Name作为e_id。我可以通过这种方式?如果不是那么另一种方式是什么?当我硬编码像这样:
http://localhost:48096/User/[email protected]它工作正常。在此先感谢
在我的_layout.cshtml我想添加一个像这样的菜单:如何在_layout.cshtml中传递参数actionLink asp.net MVC 3
@Context.User.Identity.Name作为e_id。我可以通过这种方式?如果不是那么另一种方式是什么?当我硬编码像这样:
http://localhost:48096/User/[email protected]它工作正常。在此先感谢
使用一样,如果你想传递的任何自定义HTML属性链接元素此
@Html.ActionLink("Profile", "Details", "User", new { e_id="Context.User.Identity.Name},null)
它使用此重载
public static MvcHtmlString ActionLink(
this HtmlHelper htmlHelper,
string linkText,
string actionName,
string controllerName,
Object routeValues,
Object htmlAttributes
)
,你可以替换的是第五个参数
例:
@Html.ActionLink("Profile", "Details", "User", new { e_id="yourvalue"},new {@class="myCSsClassName"})
谢谢@Shyju,我应该如何得到我的routeValues,HtmlAttributes?请描述更多一点.... – 2012-04-28 09:54:05
谢谢@Shyju,我的actionLink现在作为:<
@AwladLiton它修复了你的问题吗? – Shyju 2012-04-28 15:18:01