Parameter.Evaluate Method (HttpContext, Control)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Updates and returns the value of the Parameter object.

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

protected internal virtual object Evaluate(
	HttpContext context,
	Control control
)

Parameters

context
Type: System.Web.HttpContext

The current HttpContext of the request.

control
Type: System.Web.UI.Control

The Control the parameter is bound to. If the parameter is not bound to a control, the control parameter is ignored.

Return Value

Type: System.Object

An object that represents the updated and current value of the parameter.

The default implementation of the Evaluate method is to return null in all cases. Classes that derive from the Parameter class override the Evaluate method to return an updated parameter value. For example, the ControlParameter object returns the value of the control that it is bound to, while the QueryStringParameter object retrieves the current name/value pair from the HttpRequest object.

The following code example demonstrates how to override the Evaluate method to return the correct value in a class that is derived from the Parameter class. This code example is part of a larger example provided for the Parameter class overview.

// The Evaluate method is overridden to return the
// DataValue property instead of the DefaultValue.
protected override object Evaluate(HttpContext context, Control control) {

  if (context.Request == null)
      return null;

  return DataValue;
}

.NET Framework
Available since 2.0
Return to top
Show: