RouteParameter Class
TOC
Collapse the table of content
Expand the table of content

RouteParameter Class

.NET Framework (current version)
 

Binds the value of a URL segment to a parameter object.

Namespace:   System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

System.Object
  System.Web.UI.WebControls.Parameter
    System.Web.UI.WebControls.RouteParameter

public class RouteParameter : Parameter

NameDescription
System_CAPS_pubmethodRouteParameter()

Initializes a new instance of the RouteParameter class.

System_CAPS_protmethodRouteParameter(RouteParameter)

Initializes a new instance of the RouteParameter class by using the values of the specified instance.

System_CAPS_pubmethodRouteParameter(String, DbType, String)

Initializes a new instance of the RouteParameter class by using the specified name and database type for the parameter, and by using the specified key for the route data.

System_CAPS_pubmethodRouteParameter(String, String)

Initializes a new instance of the RouteParameter class by using the specified name for the parameter and the specified key for route data.

System_CAPS_pubmethodRouteParameter(String, TypeCode, String)

Initializes a new instance of the RouteParameter class by using the specified name and type for the parameter, and by using the specified key for the route data.

NameDescription
System_CAPS_pubpropertyConvertEmptyStringToNull

Gets or sets a value indicating whether the value that the Parameter object is bound to should be converted to null if it is String.Empty.(Inherited from Parameter.)

System_CAPS_pubpropertyDbType

Gets or sets the database type of the parameter.(Inherited from Parameter.)

System_CAPS_pubpropertyDefaultValue

Specifies a default value for the parameter, should the value that the parameter is bound to be uninitialized when the Evaluate method is called.(Inherited from Parameter.)

System_CAPS_pubpropertyDirection

Indicates whether the Parameter object is used to bind a value to a control, or the control can be used to change the value.(Inherited from Parameter.)

System_CAPS_protpropertyIsTrackingViewState

Gets a value indicating whether the Parameter object is saving changes to its view state.(Inherited from Parameter.)

System_CAPS_pubpropertyName

Gets or sets the name of the parameter.(Inherited from Parameter.)

System_CAPS_pubpropertyRouteKey

Gets or sets the name of the route segment from which to retrieve the value for the route parameter.

System_CAPS_pubpropertySize

Gets or sets the size of the parameter.(Inherited from Parameter.)

System_CAPS_pubpropertyType

Gets or sets the type of the parameter.(Inherited from Parameter.)

System_CAPS_protpropertyViewState

Gets a dictionary of state information that allows you to save and restore the view state of a Parameter object across multiple requests for the same page.(Inherited from Parameter.)

NameDescription
System_CAPS_protmethodClone()

Returns a duplicate of the current RouteParameter instance.(Overrides Parameter.Clone().)

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodEvaluate(HttpContext, Control)

Evaluates the request URL and returns the value of the parameter.(Overrides Parameter.Evaluate(HttpContext, Control).)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetDatabaseType()

Gets the DbType value that is equivalent to the CLR type of the current Parameter instance.(Inherited from Parameter.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodLoadViewState(Object)

Restores the data source view's previously saved view state.(Inherited from Parameter.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_protmethodOnParameterChanged()

Calls the OnParametersChanged method of the ParameterCollection collection that contains the Parameter object.(Inherited from Parameter.)

System_CAPS_protmethodSaveViewState()

Saves the changes to the Parameter object's view state since the time the page was posted back to the server.(Inherited from Parameter.)

System_CAPS_protmethodSetDirty()

Marks the Parameter object so its state will be recorded in view state.(Inherited from Parameter.)

System_CAPS_pubmethodToString()

Converts the value of this instance to its equivalent string representation.(Inherited from Parameter.)

System_CAPS_protmethodTrackViewState()

Causes the Parameter object to track changes to its view state so they can be stored in the control's ViewState object and persisted across requests for the same page.(Inherited from Parameter.)

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodICloneable.Clone()

Returns a duplicate of the current Parameter instance.(Inherited from Parameter.)

System_CAPS_pubinterfaceSystem_CAPS_privmethodIStateManager.LoadViewState(Object)

This API supports the product infrastructure and is not intended to be used directly from your code. Restores the data source view's previously saved view state.(Inherited from Parameter.)

System_CAPS_pubinterfaceSystem_CAPS_privmethodIStateManager.SaveViewState()

This API supports the product infrastructure and is not intended to be used directly from your code. Saves the changes to the Parameter object's view state since the time the page was posted back to the server.(Inherited from Parameter.)

System_CAPS_pubinterfaceSystem_CAPS_privmethodIStateManager.TrackViewState()

This API supports the product infrastructure and is not intended to be used directly from your code. Causes the Parameter object to track changes to its view state so they can be stored in the control's ViewState object and persisted across requests for the same page.(Inherited from Parameter.)

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIStateManager.IsTrackingViewState

This API supports the product infrastructure and is not intended to be used directly from your code. Gets a value indicating whether the Parameter object is saving changes to its view state.(Inherited from Parameter.)

If you implement ASP.NET routing in a Web site, you can use the RouteParameter object to bind the value of a segment of the requested URL to a database query or command. You can declare RouteParameter objects in markup for data source controls or the QueryExtender control.

A Visual Studio Web site project with source code is available to accompany this topic: Download.

The examples in this section show how to use RouteParameter objects in markup to pass URL parameter values to a query that is specified for a data source control.

The following example shows code in the Global.asax page that defines a route that is named ProductRoute. The route defines a URL parameter that is named productname. The route also defines an optional catchall parameter that is named culture, which can be used to specify the language in which the product description is displayed. The Product.aspx page handles requests for this route.

The following example shows the Product.aspx page. The page contains a SqlDataSource control that has a query that requires two parameters, one for the name of the product and one for the language of the product description. RouteParameter objects are used to supply the values for the query parameters. The value of the route URL parameter productname is passed to the query parameter @productname. The value of the route URL parameter culture is passed to the query parameter @culture. If a route URL does not include the URL parameter culture, a default value of "en" is used.

The following example shows a page that is named ProductLinks.aspx, which contains hyperlinks that link to the Product.aspx page by using route URLs. These hyperlinks use RouteUrl expressions to create route URLs. The first link does not include a culture route parameter. Therefore, the default value of "en" that is defined in the RouteParameter object for @culture query parameter will be used in the query. The second link provides a culture value of "fr", which causes the description to be displayed in French. For more information about how to use RouteUrl expressions, see How to: Construct URLs from Routes.

When you click the first hyperlink, you see the Product.aspx page with the following values in the GridView control:

ProductID

Name

Description

994

LL Bottom Bracket

Chromoly steel.

When you click the second hyperlink, you see the following values in the GridView control:

ProductID

Name

Description

994

LL Bottom Bracket

Acier chromé.

To run this example, add the two .aspx pages and the code in the Global.asax file to an ASP.NET Web site or Web application that defines a connection string named AdventureWorksLTConnectionString for the AdventureWorksLT database. For information about how to set up a connection to the AdventureWorksLT database, see How to: Set Up an AdventureWorksLT Sample Database for ASP.NET Development.

For more information about ASP.NET routing, see ASP.NET Routing.

.NET Framework
Available since 4.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft