Parameter.Evaluate(HttpContext, Control) Parameter.Evaluate(HttpContext, Control) Parameter.Evaluate(HttpContext, Control) Method

定義

更新並傳回 Parameter 物件的值。Updates and returns the value of the Parameter object.

protected public:
 virtual System::Object ^ Evaluate(System::Web::HttpContext ^ context, System::Web::UI::Control ^ control);
protected internal virtual object Evaluate (System.Web.HttpContext context, System.Web.UI.Control control);
abstract member Evaluate : System.Web.HttpContext * System.Web.UI.Control -> obj
override this.Evaluate : System.Web.HttpContext * System.Web.UI.Control -> obj

參數

context
HttpContext HttpContext HttpContext

要求的目前 HttpContextThe current HttpContext of the request.

control
Control Control Control

參數繫結至的 ControlThe Control the parameter is bound to. 如果參數沒有繫結至控制項,會忽略 control 參數。If the parameter is not bound to a control, the control parameter is ignored.

傳回

object,表示已更新的目前參數值。An object that represents the updated and current value of the parameter.

範例

下列程式碼範例示範如何覆寫Evaluate方法,以傳回衍生Parameter自類別之類別中的正確值。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. 這個程式碼範例是針對Parameter類別總覽提供之較大範例的一部分。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;
}
' The Evaluate method is overridden to return the
' DataValue property instead of the DefaultValue.
Protected Overrides Function Evaluate(context As HttpContext, control As Control) As Object
   If context Is Nothing Then
       Return Nothing
   Else
       Return DataValue
   End If
End Function

備註

Evaluate方法的預設執行是null在所有情況下都會傳回。The default implementation of the Evaluate method is to return null in all cases. 衍生自Parameter類別的類別會覆Evaluate寫方法,以傳回已更新的參數值。Classes that derive from the Parameter class override the Evaluate method to return an updated parameter value. 例如, ControlParameter物件會傳回其所系結之控制項的值, QueryStringParameter而物件則會從HttpRequest物件中抓取目前的名稱/值組。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.

適用於