RouteUrlExpressionBuilder.GetRouteUrl Method (Control, String)

.NET Framework (current version)
 

Creates a URL that corresponds to specified route keys for a route URL format.

Namespace:   System.Web.Compilation
Assembly:  System.Web (in System.Web.dll)

Public Shared Function GetRouteUrl (
	control As Control,
	expression As String
) As String

Parameters

control
Type: System.Web.UI.Control

The control that the expression is bound to.

expression
Type: System.String

The expression as specified in markup.

Return Value

Type: System.String

The URL that corresponds to the route URL format of the current Route object.

Exception Condition
ArgumentNullException

The control parameter is null.

InvalidOperationException

The method was unable to parse the expression that was specified in markup. For more information, see TryParseRouteExpression.

This method generates the appropriate value for the URL by calling the GetVirtualPath method of the RouteCollection object. It gets the RequestContext object from the control parameter, and it parses the route name and route parameters from the expression parameter.

.NET Framework
Available since 4.0
Return to top
Show: