Share via


ModelStateDictionary Class

Definition

Represents the result of binding a posted form to an action method, which includes information such as validation status and validation error messages.

public class ModelStateDictionary : System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<string,System.Web.WebPages.Html.ModelState>>, System.Collections.Generic.IDictionary<string,System.Web.WebPages.Html.ModelState>, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string,System.Web.WebPages.Html.ModelState>>
type ModelStateDictionary = class
    interface IDictionary<string, ModelState>
    interface ICollection<KeyValuePair<string, ModelState>>
    interface seq<KeyValuePair<string, ModelState>>
    interface IEnumerable
Public Class ModelStateDictionary
Implements ICollection(Of KeyValuePair(Of String, ModelState)), IDictionary(Of String, ModelState), IEnumerable(Of KeyValuePair(Of String, ModelState))
Inheritance
ModelStateDictionary
Implements

Constructors

ModelStateDictionary()

Initializes a new instance of the ModelStateDictionary class.

ModelStateDictionary(ModelStateDictionary)

Initializes a new instance of the ModelStateDictionary class by using values that are copied from the specified model-state dictionary.

Properties

Count

Gets the number of model states that the model-state dictionary contains.

IsReadOnly

Gets a value that indicates whether the model-state dictionary is read-only.

IsValid

Gets a value that indicates whether any error messages are associated with any model state in the model-state dictionary.

Item[String]

Gets or sets the model state that is associated with the specified key in the model-state dictionary.

Keys

Gets a list that contains the keys in the model-state dictionary.

Values

Gets a list that contains the values in the model-state dictionary.

Methods

Add(KeyValuePair<String,ModelState>)

Adds the specified item to the model-state dictionary.

Add(String, ModelState)

Adds an item that has the specified key and value to the model-state dictionary.

AddError(String, String)

Adds an error message to the model state that is associated with the specified key.

AddFormError(String)

Adds an error message to the model state that is associated with the entire form.

Clear()

Removes all items from the model-state dictionary.

Contains(KeyValuePair<String,ModelState>)

Determines whether the model-state dictionary contains the specified item.

ContainsKey(String)

Determines whether the model-state dictionary contains the specified key.

CopyTo(KeyValuePair<String,ModelState>[], Int32)

Copies the elements of the model-state dictionary to an array, starting at the specified index.

GetEnumerator()

Returns an enumerator that can be used to iterate through the collection.

IsValidField(String)

Determines whether any error messages are associated with the specified key.

Merge(ModelStateDictionary)

Copies the values from the specified model-state dictionary into this ModelStateDictionary instance, overwriting existing values when the keys are the same.

Remove(KeyValuePair<String,ModelState>)

Removes the first occurrence of the specified item from the model-state dictionary.

Remove(String)

Removes the item that has the specified key from the model-state dictionary.

SetModelValue(String, Object)

Sets the value of the model state that is associated with the specified key.

TryGetValue(String, ModelState)

Gets the model-state value that is associated with the specified key.

Explicit Interface Implementations

IEnumerable.GetEnumerator()

Returns an enumerator that can be used to iterate through the model-state dictionary.

Applies to