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方法來取得具有參數名為路由的 URLproductidcategoryThe 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. 這個範例假設您已建立HyperLink控制項,名為HyperLink1This 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. 這個方法會轉換傳入的物件routeParametersRouteValueDictionary物件使用RouteValueDictionary.RouteValueDictionary(Object)建構函式。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.

範例

下列範例示範如何呼叫這個方法來取得具有參數名為路由的 URLproductidcategoryThe following example shows how to call this method to get the URL of a route that has parameters that are named productid and category. 這個範例假設您已建立HyperLink控制項,名為HyperLink1This 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.

範例

下列範例示範如何呼叫這個方法來取得名為路由的 URLProduct且具有名為的參數productidcategoryThe 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. 這個範例假設您已建立HyperLink控制項,名為HyperLink1This 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. 這個方法會轉換傳入的物件routeParametersRouteValueDictionary物件使用RouteValueDictionary.RouteValueDictionary(Object)建構函式。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.

範例

下列範例示範如何呼叫這個方法來取得名為路由的 URLProduct且具有名為的參數productidcategoryThe 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. 這個範例假設您已建立HyperLink控制項,名為HyperLink1This 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.

另請參閱

適用於