Controller.TryUpdateModel Method
Updates the specified model instance using values from the controller's current value provider.
Assembly: System.Web.Mvc (in System.Web.Mvc.dll)
| Name | Description | |
|---|---|---|
![]() | TryUpdateModel<'TModel>('TModel) | Updates the specified model instance using values from the controller's current value provider. |
![]() | TryUpdateModel<'TModel>('TModel, IValueProvider) | Updates the specified model instance using values from the value provider. |
![]() | TryUpdateModel<'TModel>('TModel, String) | Updates the specified model instance using values from the controller's current value provider and a prefix. |
![]() | TryUpdateModel<'TModel>('TModel, String, IValueProvider) | Updates the specified model instance using values from the value provider and a list of properties to include. |
![]() | TryUpdateModel<'TModel>('TModel, String, String[]) | Updates the specified model instance using values from the controller's current value provider, a prefix, and included properties. |
![]() | TryUpdateModel<'TModel>('TModel, String, String[], IValueProvider) | Updates the specified model instance using values from the value provider, a prefix, and included properties. |
![]() | TryUpdateModel<'TModel>('TModel, String, String[], String[]) | Updates the specified model instance using values from the controller's current value provider, a prefix, a list of properties to exclude, and a list of properties to include. |
![]() | TryUpdateModel<'TModel>('TModel, String, String[], String[], IValueProvider) | Updates the specified model instance using values from the value provider, a prefix, a list of properties to exclude , and a list of properties to include. |
![]() | TryUpdateModel<'TModel>('TModel, String[]) | Updates the specified model instance using values from the controller's current value provider and included properties. |
![]() | TryUpdateModel<'TModel>('TModel, String[], IValueProvider) | Updates the specified model instance using values from the value provider and a list of properties to include. |
Controller.TryUpdateModel<'TModel> Method ('TModel)
Updates the specified model instance using values from the controller's current value provider.
| Exception | Condition |
|---|---|
| ArgumentNullException | The model parameter or the ValueProvider property is null. |
You do not have to explicitly specify the generic parameter TModel. Instead, you can let the C# or Visual Basic type inference engine determine the generic parameter TModel by omitting it.
Controller.TryUpdateModel<'TModel> Method ('TModel, IValueProvider)
Updates the specified model instance using values from the value provider.
member TryUpdateModel<'TModel when 'TModel : not struct> : model:'TModel * valueProvider:IValueProvider -> bool
Parameters
- model
-
Type:
TModel
The model instance to update.
- valueProvider
-
Type:
System.Web.Mvc.IValueProvider
A dictionary of values that is used to update the model.
Type Parameters
- TModel
The type of the model object.
The TryUpdateModel method is like the UpdateModel method except that the TryUpdateModel method does not throw an InvalidOperationException exception if the updated model state is not valid.
Controller.TryUpdateModel<'TModel> Method ('TModel, String)
Updates the specified model instance using values from the controller's current value provider and a prefix.
member TryUpdateModel<'TModel when 'TModel : not struct> : model:'TModel * prefix:string -> bool
Parameters
- model
-
Type:
TModel
The model instance to update.
- prefix
-
Type:
System.String
The prefix to use when looking up values in the value provider.
Type Parameters
- TModel
The type of the model object.
| Exception | Condition |
|---|---|
| ArgumentNullException | The model parameter or the ValueProvider property is null. |
You do not have to explicitly specify the generic parameter TModel. Instead, you can let the C# or Visual Basic type inference engine determine the generic parameter TModel by omitting it.
Controller.TryUpdateModel<'TModel> Method ('TModel, String, IValueProvider)
Updates the specified model instance using values from the value provider and a list of properties to include.
member TryUpdateModel<'TModel when 'TModel : not struct> : model:'TModel * prefix:string * valueProvider:IValueProvider -> bool
Parameters
- model
-
Type:
TModel
The model instance to update.
- prefix
-
Type:
System.String
A list of properties of the model to update.
- valueProvider
-
Type:
System.Web.Mvc.IValueProvider
A dictionary of values that is used to update the model.
Type Parameters
- TModel
The type of the model object.
The TryUpdateModel method is like the UpdateModel method except that the TryUpdateModel method does not throw an InvalidOperationException exception if the updated model state is not valid.
Controller.TryUpdateModel<'TModel> Method ('TModel, String, String[])
Updates the specified model instance using values from the controller's current value provider, a prefix, and included properties.
member TryUpdateModel<'TModel when 'TModel : not struct> : model:'TModel * prefix:string * includeProperties:string[] -> bool
Parameters
- model
-
Type:
TModel
The model instance to update.
- prefix
-
Type:
System.String
The prefix to use when looking up values in the value provider.
- includeProperties
-
Type:
System.String[]
A list of properties of the model to update.
Type Parameters
- TModel
The type of the model object.
| Exception | Condition |
|---|---|
| ArgumentNullException | The model parameter or the ValueProvider property is null. |
You do not have to explicitly specify the generic parameter TModel. Instead, you can let the C# or Visual Basic type inference engine determine the generic parameter TModel by omitting it.
Controller.TryUpdateModel<'TModel> Method ('TModel, String, String[], IValueProvider)
Updates the specified model instance using values from the value provider, a prefix, and included properties.
member TryUpdateModel<'TModel when 'TModel : not struct> : model:'TModel * prefix:string * includeProperties:string[] * valueProvider:IValueProvider -> bool
Parameters
- model
-
Type:
TModel
The model instance to update.
- prefix
-
Type:
System.String
The prefix to use when looking up values in the value provider.
- includeProperties
-
Type:
System.String[]
A list of properties of the model to update.
- valueProvider
-
Type:
System.Web.Mvc.IValueProvider
A dictionary of values that is used to update the model.
Type Parameters
- TModel
The type of the model object.
You do not have to explicitly specify the generic parameter TModel. Instead, you can let the C# or Visual Basic type inference engine determine the generic parameter TModel by omitting the generic parameter.
The TryUpdateModel method is like the UpdateModel method except that the TryUpdateModel method does not throw an InvalidOperationException exception if the updated model state is not valid.
Controller.TryUpdateModel<'TModel> Method ('TModel, String, String[], String[])
Updates the specified model instance using values from the controller's current value provider, a prefix, a list of properties to exclude, and a list of properties to include.
member TryUpdateModel<'TModel when 'TModel : not struct> : model:'TModel * prefix:string * includeProperties:string[] * excludeProperties:string[] -> bool
Parameters
- model
-
Type:
TModel
The model instance to update.
- prefix
-
Type:
System.String
The prefix to use when looking up values in the value provider.
- includeProperties
-
Type:
System.String[]
A list of properties of the model to update.
- excludeProperties
-
Type:
System.String[]
A list of properties to explicitly exclude from the update. These are excluded even if they are listed in the includeProperties parameter list.
Type Parameters
- TModel
The type of the model object.
| Exception | Condition |
|---|---|
| ArgumentNullException | The model parameter or the ValueProvider property is null. |
You do not have to explicitly specify the generic parameter TModel. Instead, you can let the C# or Visual Basic type inference engine determine the generic parameter TModel by omitting it.
Controller.TryUpdateModel<'TModel> Method ('TModel, String, String[], String[], IValueProvider)
Updates the specified model instance using values from the value provider, a prefix, a list of properties to exclude , and a list of properties to include.
member TryUpdateModel<'TModel when 'TModel : not struct> : model:'TModel * prefix:string * includeProperties:string[] * excludeProperties:string[] * valueProvider:IValueProvider -> bool
Parameters
- model
-
Type:
TModel
The model instance to update.
- prefix
-
Type:
System.String
The prefix to use when looking up values in the value provider.
- includeProperties
-
Type:
System.String[]
A list of properties of the model to update.
- excludeProperties
-
Type:
System.String[]
A list of properties to explicitly exclude from the update. These are excluded even if they are listed in the includeProperties parameter list.
- valueProvider
-
Type:
System.Web.Mvc.IValueProvider
A dictionary of values that is used to update the model.
Type Parameters
- TModel
The type of the model object.
You do not have to explicitly specify the generic parameter TModel. Instead, you can let the C# or Visual Basic type inference engine determine the generic parameter TModel by omitting it.
Controller.TryUpdateModel<'TModel> Method ('TModel, String[])
Updates the specified model instance using values from the controller's current value provider and included properties.
member TryUpdateModel<'TModel when 'TModel : not struct> : model:'TModel * includeProperties:string[] -> bool
Parameters
- model
-
Type:
TModel
The model instance to update.
- includeProperties
-
Type:
System.String[]
A list of properties of the model to update.
Type Parameters
- TModel
The type of the model object.
Controller.TryUpdateModel<'TModel> Method ('TModel, String[], IValueProvider)
Updates the specified model instance using values from the value provider and a list of properties to include.
member TryUpdateModel<'TModel when 'TModel : not struct> : model:'TModel * includeProperties:string[] * valueProvider:IValueProvider -> bool
Parameters
- model
-
Type:
TModel
The model instance to update.
- includeProperties
-
Type:
System.String[]
A list of properties of the model to update.
- valueProvider
-
Type:
System.Web.Mvc.IValueProvider
A dictionary of values that is used to update the model.
Type Parameters
- TModel
The type of the model object.
You do not have to explicitly specify the generic parameter TModel. Instead, you can let the C# or Visual Basic type inference engine determine the generic parameter TModel by omitting it.
The TryUpdateModel method is like the UpdateModel method except that the TryUpdateModel method does not throw an InvalidOperationException exception if the updated model state is not valid.
