Control.GetRouteUrl Control.GetRouteUrl Control.GetRouteUrl Control.GetRouteUrl Method

定義

取得 URL,此 URL 對應於一組路由參數,而且會選擇性地對應到路由名稱。Gets the URL that corresponds to a set of route parameters, and optionally to a route name.

多載

GetRouteUrl(Object) GetRouteUrl(Object) GetRouteUrl(Object) GetRouteUrl(Object)

取得會對應於一組路由參數的 URL。Gets the URL that corresponds to a set of route parameters.

GetRouteUrl(RouteValueDictionary) GetRouteUrl(RouteValueDictionary) GetRouteUrl(RouteValueDictionary) GetRouteUrl(RouteValueDictionary)

取得會對應於一組路由參數的 URL。Gets the URL that corresponds to a set of route parameters.

GetRouteUrl(String, Object) GetRouteUrl(String, Object) GetRouteUrl(String, Object) GetRouteUrl(String, Object)

取得 URL,此 URL 對應於一組路由參數及一個路由名稱。Gets the URL that corresponds to a set of route parameters and a route name.

GetRouteUrl(String, RouteValueDictionary) GetRouteUrl(String, RouteValueDictionary) GetRouteUrl(String, RouteValueDictionary) GetRouteUrl(String, RouteValueDictionary)

取得 URL,此 URL 對應於一組路由參數及一個路由名稱。Gets the URL that corresponds to a set of route parameters and a route name.

備註

提供此方法是為了方便撰寫程式碼。This method is provided for coding convenience. 這相當於呼叫RouteCollection.GetVirtualPath方法。It is equivalent to calling the RouteCollection.GetVirtualPath method.

GetRouteUrl(Object) GetRouteUrl(Object) GetRouteUrl(Object) GetRouteUrl(Object)

取得會對應於一組路由參數的 URL。Gets the URL that corresponds to a set of route parameters.

public:
 System::String ^ GetRouteUrl(System::Object ^ routeParameters);
public string GetRouteUrl (object routeParameters);
member this.GetRouteUrl : obj -> string
Public Function GetRouteUrl (routeParameters As Object) As String

參數

routeParameters
Object Object Object Object

路由參數。The route parameters.

傳回

對應於指定之路由參數的 URL。The URL that corresponds to the specified route parameters.

範例

下列範例顯示如何呼叫Control.GetRouteUrl方法,以取得具有名為productidcategory之參數的路由 URL。The following example shows how to call the Control.GetRouteUrl method to get the URL of a route that has parameters that are named productid and category. 這個範例假設您已建立HyperLinkHyperLink1為的控制項。This example assumes that you have created a HyperLink control that is named HyperLink1.

HyperLink1.NavigateUrl = HyperLink1.GetRouteUrl(  
  New With {.productid = "1", .category = "widgets"})  
HyperLink1.NavigateUrl = HyperLink1.GetRouteUrl(  
  new { productid = "1", category = "widgets" });  

備註

提供此方法是為了方便撰寫程式碼。This method is provided for coding convenience. 這相當於呼叫RouteCollection.GetVirtualPath(RequestContext, RouteValueDictionary)方法。It is equivalent to calling the RouteCollection.GetVirtualPath(RequestContext, RouteValueDictionary) method. 這個方法會使用routeParameters RouteValueDictionary.RouteValueDictionary(Object)此函式,將傳入的RouteValueDictionary物件轉換成物件。This method converts the object that is passed in routeParameters to a RouteValueDictionary object by using the RouteValueDictionary.RouteValueDictionary(Object) constructor.

另請參閱

GetRouteUrl(RouteValueDictionary) GetRouteUrl(RouteValueDictionary) GetRouteUrl(RouteValueDictionary) GetRouteUrl(RouteValueDictionary)

取得會對應於一組路由參數的 URL。Gets the URL that corresponds to a set of route parameters.

public:
 System::String ^ GetRouteUrl(System::Web::Routing::RouteValueDictionary ^ routeParameters);
public string GetRouteUrl (System.Web.Routing.RouteValueDictionary routeParameters);
member this.GetRouteUrl : System.Web.Routing.RouteValueDictionary -> string
Public Function GetRouteUrl (routeParameters As RouteValueDictionary) As String

參數

routeParameters
RouteValueDictionary RouteValueDictionary RouteValueDictionary RouteValueDictionary

路由參數。The route parameters.

傳回

對應於指定之路由參數的 URL。The URL that corresponds to the specified route parameters.

範例

下列範例示範如何呼叫這個方法,以取得具有名為productidcategory之參數的路由 URL。The following example shows how to call this method to get the URL of a route that has parameters that are named productid and category. 這個範例假設您已建立HyperLinkHyperLink1為的控制項。This example assumes that you have created a HyperLink control that is named HyperLink1.

HyperLink1.NavigateUrl = HyperLink1.GetRouteUrl(  
  new RouteValueDictionary {productId="1", category="widgets"})  
HyperLink1.NavigateUrl = HyperLink1.GetRouteUrl(  
  (new RouteValueDictionary {productId="1", category="widgets"});  

備註

提供此方法是為了方便撰寫程式碼。This method is provided for coding convenience. 這相當於呼叫RouteCollection.GetVirtualPath(RequestContext, RouteValueDictionary)方法。It is equivalent to calling the RouteCollection.GetVirtualPath(RequestContext, RouteValueDictionary) method.

另請參閱

GetRouteUrl(String, Object) GetRouteUrl(String, Object) GetRouteUrl(String, Object) GetRouteUrl(String, Object)

取得 URL,此 URL 對應於一組路由參數及一個路由名稱。Gets the URL that corresponds to a set of route parameters and a route name.

public:
 System::String ^ GetRouteUrl(System::String ^ routeName, System::Object ^ routeParameters);
public string GetRouteUrl (string routeName, object routeParameters);
member this.GetRouteUrl : string * obj -> string
Public Function GetRouteUrl (routeName As String, routeParameters As Object) As String

參數

routeName
String String String String

路由的名稱。The name of the route.

routeParameters
Object Object Object Object

路由參數。The route parameters.

傳回

對應於指定之路由參數及路由名稱的 URL。The URL that corresponds to the specified route parameters and route name.

範例

下列範例示範如何呼叫這個方法,以取得名Product為的路由 URL,並具有名為productidcategory的參數。The following example shows how to call this method to get the URL of a route that is named Product and has parameters that are named productid and category. 這個範例假設您已建立HyperLinkHyperLink1為的控制項。This example assumes that you have created a HyperLink control that is named HyperLink1.

HyperLink1.NavigateUrl = HyperLink1.GetRouteUrl("Product",  
  New With {.productid = "1", .category = "widgets"})  
HyperLink1.NavigateUrl = HyperLink1.GetRouteUrl("Product",  
  new { productid = "1", category = "widgets" });  

備註

提供此方法是為了方便撰寫程式碼。This method is provided for coding convenience. 這相當於呼叫RouteCollection.GetVirtualPath(RequestContext, String, RouteValueDictionary)方法。It is equivalent to calling the RouteCollection.GetVirtualPath(RequestContext, String, RouteValueDictionary) method. 這個方法會使用routeParameters RouteValueDictionary.RouteValueDictionary(Object)此函式,將傳入的RouteValueDictionary物件轉換成物件。This method converts the object that is passed in routeParameters to a RouteValueDictionary object by using the RouteValueDictionary.RouteValueDictionary(Object) constructor.

另請參閱

GetRouteUrl(String, RouteValueDictionary) GetRouteUrl(String, RouteValueDictionary) GetRouteUrl(String, RouteValueDictionary) GetRouteUrl(String, RouteValueDictionary)

取得 URL,此 URL 對應於一組路由參數及一個路由名稱。Gets the URL that corresponds to a set of route parameters and a route name.

public:
 System::String ^ GetRouteUrl(System::String ^ routeName, System::Web::Routing::RouteValueDictionary ^ routeParameters);
public string GetRouteUrl (string routeName, System.Web.Routing.RouteValueDictionary routeParameters);
member this.GetRouteUrl : string * System.Web.Routing.RouteValueDictionary -> string
Public Function GetRouteUrl (routeName As String, routeParameters As RouteValueDictionary) As String

參數

routeName
String String String String

路由的名稱。The name of the route.

routeParameters
RouteValueDictionary RouteValueDictionary RouteValueDictionary RouteValueDictionary

路由參數。The route parameters.

傳回

對應於指定之路由參數及路由名稱的 URL。The URL that corresponds to the specified route parameters and route name.

範例

下列範例示範如何呼叫這個方法,以取得名Product為的路由 URL,並具有名為productidcategory的參數。The following example shows how to call this method to get the URL of a route that is named Product and has parameters that are named productid and category. 這個範例假設您已建立HyperLinkHyperLink1為的控制項。This example assumes that you have created a HyperLink control that is named HyperLink1.

HyperLink1.NavigateUrl = HyperLink1.GetRouteUrl("Product",  
  new RouteValueDictionary {productId="1", category="widgets"})  
HyperLink1.NavigateUrl = HyperLink1.GetRouteUrl("Product",  
  (new RouteValueDictionary {productId="1", category="widgets"});  

備註

提供此方法是為了方便撰寫程式碼。This method is provided for coding convenience. 這相當於呼叫RouteCollection.GetVirtualPath(RequestContext, String, RouteValueDictionary)方法。It is equivalent to calling the RouteCollection.GetVirtualPath(RequestContext, String, RouteValueDictionary) method.

另請參閱

適用於