Επεξεργασία

Κοινή χρήση μέσω


Control.GetRouteUrl Method

Definition

Gets the URL that corresponds to a set of route parameters, and optionally to a route name.

Overloads

GetRouteUrl(Object)

Gets the URL that corresponds to a set of route parameters.

GetRouteUrl(RouteValueDictionary)

Gets the URL that corresponds to a set of route parameters.

GetRouteUrl(String, Object)

Gets the URL that corresponds to a set of route parameters and a route name.

GetRouteUrl(String, RouteValueDictionary)

Gets the URL that corresponds to a set of route parameters and a route name.

Remarks

This method is provided for coding convenience. It is equivalent to calling the RouteCollection.GetVirtualPath method.

GetRouteUrl(Object)

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

Parameters

routeParameters
Object

The route parameters.

Returns

The URL that corresponds to the specified route parameters.

Examples

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. 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" });

Remarks

This method is provided for coding convenience. It is equivalent to calling the RouteCollection.GetVirtualPath(RequestContext, RouteValueDictionary) method. This method converts the object that is passed in routeParameters to a RouteValueDictionary object by using the RouteValueDictionary.RouteValueDictionary(Object) constructor.

See also

Applies to

GetRouteUrl(RouteValueDictionary)

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

Parameters

routeParameters
RouteValueDictionary

The route parameters.

Returns

The URL that corresponds to the specified route parameters.

Examples

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. 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"});

Remarks

This method is provided for coding convenience. It is equivalent to calling the RouteCollection.GetVirtualPath(RequestContext, RouteValueDictionary) method.

See also

Applies to

GetRouteUrl(String, Object)

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

Parameters

routeName
String

The name of the route.

routeParameters
Object

The route parameters.

Returns

The URL that corresponds to the specified route parameters and route name.

Examples

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. 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" });

Remarks

This method is provided for coding convenience. It is equivalent to calling the RouteCollection.GetVirtualPath(RequestContext, String, RouteValueDictionary) method. This method converts the object that is passed in routeParameters to a RouteValueDictionary object by using the RouteValueDictionary.RouteValueDictionary(Object) constructor.

See also

Applies to

GetRouteUrl(String, RouteValueDictionary)

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

Parameters

routeName
String

The name of the route.

routeParameters
RouteValueDictionary

The route parameters.

Returns

The URL that corresponds to the specified route parameters and route name.

Examples

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. 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"});

Remarks

This method is provided for coding convenience. It is equivalent to calling the RouteCollection.GetVirtualPath(RequestContext, String, RouteValueDictionary) method.

See also

Applies to