Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Controller.TryUpdateModel Method

 

Updates the specified model instance using values from the controller's current value provider.

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

NameDescription
System_CAPS_protmethodTryUpdateModel<TModel>(TModel)

Updates the specified model instance using values from the controller's current value provider.

System_CAPS_protmethodTryUpdateModel<TModel>(TModel, IValueProvider)

Updates the specified model instance using values from the value provider.

System_CAPS_protmethodTryUpdateModel<TModel>(TModel, String)

Updates the specified model instance using values from the controller's current value provider and a prefix.

System_CAPS_protmethodTryUpdateModel<TModel>(TModel, String, IValueProvider)

Updates the specified model instance using values from the value provider and a list of properties to include.

System_CAPS_protmethodTryUpdateModel<TModel>(TModel, String, String[])

Updates the specified model instance using values from the controller's current value provider, a prefix, and included properties.

System_CAPS_protmethodTryUpdateModel<TModel>(TModel, String, String[], IValueProvider)

Updates the specified model instance using values from the value provider, a prefix, and included properties.

System_CAPS_protmethodTryUpdateModel<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.

System_CAPS_protmethodTryUpdateModel<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.

System_CAPS_protmethodTryUpdateModel<TModel>(TModel, String[])

Updates the specified model instance using values from the controller's current value provider and included properties.

System_CAPS_protmethodTryUpdateModel<TModel>(TModel, String[], IValueProvider)

Updates the specified model instance using values from the value provider and a list of properties to include.

Return to top

Controller.TryUpdateModel<TModel> Method (TModel)

Updates the specified model instance using values from the controller's current value provider.

protected internal bool TryUpdateModel<TModel>(
	TModel model
)
where TModel : class

Parameters

model
Type: TModel

The model instance to update.

Return Value

Type: System.Boolean

true if the update is successful; otherwise, false.

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.

Return to top

Controller.TryUpdateModel<TModel> Method (TModel, IValueProvider)

Updates the specified model instance using values from the value provider.

protected internal bool TryUpdateModel<TModel>(
	TModel model,
	IValueProvider valueProvider
)
where TModel : class

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.

Return Value

Type: System.Boolean

true if the update is successful; otherwise, false.

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.

Return to top

Controller.TryUpdateModel<TModel> Method (TModel, String)

Updates the specified model instance using values from the controller's current value provider and a prefix.

protected internal bool TryUpdateModel<TModel>(
	TModel model,
	string prefix
)
where TModel : class

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.

Return Value

Type: System.Boolean

true if the update is successful; otherwise, false.

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.

Return to top

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.

protected internal bool TryUpdateModel<TModel>(
	TModel model,
	string prefix,
	IValueProvider valueProvider
)
where TModel : class

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.

Return Value

Type: System.Boolean

true if the update is successful; otherwise, false.

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.

Return to top

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.

protected internal bool TryUpdateModel<TModel>(
	TModel model,
	string prefix,
	string[] includeProperties
)
where TModel : class

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.

Return Value

Type: System.Boolean

true if the update is successful; otherwise, false.

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.

Return to top

Controller.TryUpdateModel<TModel> Method (TModel, String, String[], IValueProvider)

Updates the specified model instance using values from the value provider, a prefix, and included properties.

protected internal bool TryUpdateModel<TModel>(
	TModel model,
	string prefix,
	string[] includeProperties,
	IValueProvider valueProvider
)
where TModel : class

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.

Return Value

Type: System.Boolean

true if the update is successful; otherwise, false.

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.

Return to top

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.

protected internal bool TryUpdateModel<TModel>(
	TModel model,
	string prefix,
	string[] includeProperties,
	string[] excludeProperties
)
where TModel : class

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.

Return Value

Type: System.Boolean

true if the update is successful; otherwise, false.

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.

Return to top

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.

protected internal bool TryUpdateModel<TModel>(
	TModel model,
	string prefix,
	string[] includeProperties,
	string[] excludeProperties,
	IValueProvider valueProvider
)
where TModel : class

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.

Return Value

Type: System.Boolean

true if the update is successful; otherwise, false.

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.

Return to top

Controller.TryUpdateModel<TModel> Method (TModel, String[])

Updates the specified model instance using values from the controller's current value provider and included properties.

protected internal bool TryUpdateModel<TModel>(
	TModel model,
	string[] includeProperties
)
where TModel : class

Parameters

model
Type: TModel

The model instance to update.

includeProperties
Type: System.String[]

A list of properties of the model to update.

Return Value

Type: System.Boolean

true if the update is successful; otherwise, false.

Type Parameters

TModel

The type of the model object.

Return to top

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.

protected internal bool TryUpdateModel<TModel>(
	TModel model,
	string[] includeProperties,
	IValueProvider valueProvider
)
where TModel : class

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.

Return Value

Type: System.Boolean

true if the update is successful; otherwise, false.

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.

Return to top
Show:
© 2015 Microsoft