标签:
以下使用参数文字说明:
重载一:Html.ActionLink("linkText","actionName")【默认当前页面控制器】
调用:@Html.ActionLink("默认当前页面控制器", "About")
生成效果:<a href="/Home/About">默认当前页面控制器</a>
重载二:Html.ActionLink("linkText","actionName",routeValues)
调用:
routeValues Is object:
@Html.ActionLink("默认当前页面控制器", "About", new { id = 1, type = "Dic" })
routeValues Is RouteValueDictionary:
@RouteValueDictionary Dictionary = new RouteValueDictionary();
@Dictionary["id"] = 1;
@Dictionary["type"] = "Dic";
@Html.ActionLink("默认当前页面控制器", "About", Dictionary)
生成效果:<a href="/Home/About?classid=1">默认当前页面控制器</a>
重载三:Html.ActionLink("linkText","actionName","controlName")
调用:@Html.ActionLink("默认当前页面控制器", "About", "Home")
生成效果:<a href="/Home/About">默认当前页面控制器</a>
重载四:Html.ActionLink("linkText","actionName",routeValues,htmlAttributes)
调用:
htmlAttributes Is object:
@Html.ActionLink("首页", "Index", "Home", null, new { @class = "active", target = "_blank" })%>【注:由于class是保留关键字,所以一定要写成@class】
htmlAttributes Is IDictionary:
@IDictionary<string, object> AttrDictionary = new Dictionary<string, object>();
@AttrDictionary["class"] = "active";
@AttrDictionary["target"] = "_blank";
生成效果:<a class="active" href="/" target="_blank">首页</a>
重载五:Html.ActionLink("linkText","actionName","controlName","protocol","hostName","fragment",routeValues,htmlAttributes)
调用:@Html.ActionLink("关于我们", "About", "Home", "http", "localhost", "top", null, null)
生成效果:<a href="http://localhost:12120/Home/About#top">关于我们</a>
标签:
原文地址:http://www.cnblogs.com/jack022/p/4785073.html