2012-08-24 57 views
1

示例:Html.ActionLink中的使用/測試#測試

我有一個網頁www.test.com/,然後如果我點擊鏈接, <a href="#test">然後該頁面將跳轉到ID爲'test'的元素的任何位置。是否可以在Html.ActionLink()中實現相同的事情。很明顯,我可以保持相同的格式,但當用#id在頁面之間導航時,我也需要它。

所以我在尋找的東西,我可以把Html.ActionLink("Text", "Action", "Controller", "id")

回答

2

你必須使用片段參數:

public static MvcHtmlString ActionLink(
    this HtmlHelper htmlHelper, 
    string linkText, 
    string actionName, 
    string controllerName, 
    string protocol, 
    string hostName, 
    string fragment, 
    Object routeValues, 
    Object htmlAttributes 
) 

http://msdn.microsoft.com/en-us/library/dd460522.aspx

+0

啊謝謝這是輝煌的。我確實看過那裏,但我不知道它被稱爲主播。 – ediblecode