共用方式為


ViewDataDictionary<TModel>.SetModel Method

Sets the data model to use for the view.

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

Syntax

'Declaration
Protected Overrides Sub SetModel ( _
    value As Object _
)
protected override void SetModel(
    Object value
)
protected:
virtual void SetModel(
    Object^ value
) override

Parameters

Exceptions

Exception Condition
InvalidOperationException

An error occurred while the model was being set.

Remarks

This method executes before the derived type's instance constructor executes. Derived types must take this into consideration. For example, the logic in the SetModel method must not depend on the this pointer (Me in Visual Basic) to reference a fully constructed object.

See Also

Reference

ViewDataDictionary<TModel> Class

System.Web.Mvc Namespace