ModelMethodContext.TryUpdateModel 方法

定义

使用来自值提供程序的值更新指定的模型实例。Updates the specified model instance using values from a value provider.

重载

TryUpdateModel<TModel>(TModel)

使用来自值提供程序的值更新指定的模型实例。Updates the specified model instance using values from a value provider.

TryUpdateModel<TModel>(TModel, IValueProvider)

使用来自指定值提供程序的值更新指定的模型实例。Updates the specified model instance using values from the specified value provider.

注解

有关如何在 Web 窗体中使用模型绑定的教程系列,请参阅 模型绑定和 Web 窗体For a tutorial series on using model binding with Web Forms, see Model Binding and Web Forms.

TryUpdateModel<TModel>(TModel)

使用来自值提供程序的值更新指定的模型实例。Updates the specified model instance using values from a value provider.

public:
generic <typename TModel>
 where TModel : class virtual bool TryUpdateModel(TModel model);
public virtual bool TryUpdateModel<TModel> (TModel model) where TModel : class;
abstract member TryUpdateModel : 'Model -> bool (requires 'Model : null)
override this.TryUpdateModel : 'Model -> bool (requires 'Model : null)
Public Overridable Function TryUpdateModel(Of TModel As Class) (model As TModel) As Boolean

类型参数

TModel

模型的类型。The type of the model.

参数

model
TModel

模型。The model.

返回

Boolean

如果模型绑定成功,则为 true;否则为 falsetrue if model binding is successful; otherwise, false.

注解

有关如何在 Web 窗体中使用模型绑定的教程系列,请参阅 模型绑定和 Web 窗体For a tutorial series on using model binding with Web Forms, see Model Binding and Web Forms.

适用于

TryUpdateModel<TModel>(TModel, IValueProvider)

使用来自指定值提供程序的值更新指定的模型实例。Updates the specified model instance using values from the specified value provider.

public:
generic <typename TModel>
 where TModel : class virtual bool TryUpdateModel(TModel model, System::Web::ModelBinding::IValueProvider ^ valueProvider);
public virtual bool TryUpdateModel<TModel> (TModel model, System.Web.ModelBinding.IValueProvider valueProvider) where TModel : class;
abstract member TryUpdateModel : 'Model * System.Web.ModelBinding.IValueProvider -> bool (requires 'Model : null)
override this.TryUpdateModel : 'Model * System.Web.ModelBinding.IValueProvider -> bool (requires 'Model : null)
Public Overridable Function TryUpdateModel(Of TModel As Class) (model As TModel, valueProvider As IValueProvider) As Boolean

类型参数

TModel

模型的类型。The type of the model.

参数

model
TModel

模型。The model.

valueProvider
IValueProvider

值提供程序。The value provider.

返回

Boolean

如果模型绑定成功,则为 true;否则为 falsetrue if model binding is successful; otherwise, false.

注解

有关如何在 Web 窗体中使用模型绑定的教程系列,请参阅 模型绑定和 Web 窗体For a tutorial series on using model binding with Web Forms, see Model Binding and Web Forms.

适用于