Page.TryUpdateModel Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Updates the specified model instance using values from a value provider.
TryUpdateModel<TModel>(TModel) |
Updates the specified model instance using values from the data-bound control. |
TryUpdateModel<TModel>(TModel, IValueProvider) |
Updates the model instance using values from the specified value provider. |
For a tutorial series on using model binding with Web Forms, see Model Binding and Web Forms.
Updates the specified model instance using values from the data-bound control.
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
Type Parameters
- TModel
The type of the model.
Parameters
- model
- TModel
The model.
Returns
true
if model binding is successful; otherwise, false
.
Remarks
This method should only be called from a method that is specified by a data-bound control's UpdateMethod
or InsertMethod
property.
For a tutorial series on using model binding with Web Forms, see Model Binding and Web Forms.
Applies to
.NET Framework 4.8.1 and other versions
Product | Versions |
---|---|
.NET Framework | 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Updates the 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
Type Parameters
- TModel
The type of the model.
Parameters
- model
- TModel
The model.
- valueProvider
- IValueProvider
The value provider.
Returns
true
if model binding is successful; otherwise, false
.
Remarks
For a tutorial series on using model binding with Web Forms, see Model Binding and Web Forms.
Applies to
.NET Framework 4.8.1 and other versions
Product | Versions |
---|---|
.NET Framework | 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: