ModelStateDictionary ModelStateDictionary ModelStateDictionary Class

Definition

Represents the state of an attempt to bind a posted form to an action method, which includes validation information.

[Serializable]
public class ModelStateDictionary : System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<string,System.Web.Mvc.ModelState>>, System.Collections.Generic.IDictionary<string,System.Web.Mvc.ModelState>, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string,System.Web.Mvc.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
ModelStateDictionaryModelStateDictionaryModelStateDictionary
Attributes
SerializableAttribute
Implements

Constructors

ModelStateDictionary() ModelStateDictionary() ModelStateDictionary()

Initializes a new instance of the ModelStateDictionary class.

ModelStateDictionary(ModelStateDictionary) ModelStateDictionary(ModelStateDictionary) ModelStateDictionary(ModelStateDictionary)

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

Properties

Count Count Count

Gets the number of key/value pairs in the collection.

IsReadOnly IsReadOnly IsReadOnly

Gets a value that indicates whether the collection is read-only.

IsValid IsValid IsValid

Gets a value that indicates whether this instance of the model-state dictionary is valid.

Item[String] Item[String] Item[String]

Gets or sets the value that is associated with the specified key.

Keys Keys Keys

Gets a collection that contains the keys in the dictionary.

Values Values Values

Gets a collection that contains the values in the dictionary.

Methods

Add(KeyValuePair<String,ModelState>) Add(KeyValuePair<String,ModelState>) Add(KeyValuePair<String,ModelState>)

Adds the specified item to the model-state dictionary.

Add(String, ModelState) Add(String, ModelState) Add(String, ModelState)

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

AddModelError(String, Exception) AddModelError(String, Exception) AddModelError(String, Exception)

Adds the specified model error to the errors collection for the model-state dictionary that is associated with the specified key.

AddModelError(String, String) AddModelError(String, String) AddModelError(String, String)

Adds the specified error message to the errors collection for the model-state dictionary that is associated with the specified key.

Clear() Clear() Clear()

Removes all items from the model-state dictionary.

Contains(KeyValuePair<String,ModelState>) Contains(KeyValuePair<String,ModelState>) Contains(KeyValuePair<String,ModelState>)

Determines whether the model-state dictionary contains a specific value.

ContainsKey(String) ContainsKey(String) ContainsKey(String)

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

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

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

GetEnumerator() GetEnumerator() GetEnumerator()

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

IsValidField(String) IsValidField(String) IsValidField(String)

Determines whether there are any ModelError objects that are associated with or prefixed with the specified key.

Merge(ModelStateDictionary) Merge(ModelStateDictionary) Merge(ModelStateDictionary)

Copies the values from the specified ModelStateDictionary object into this dictionary, overwriting existing values if keys are the same.

Remove(KeyValuePair<String,ModelState>) Remove(KeyValuePair<String,ModelState>) Remove(KeyValuePair<String,ModelState>)

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

Remove(String) Remove(String) Remove(String)

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

SetModelValue(String, ValueProviderResult) SetModelValue(String, ValueProviderResult) SetModelValue(String, ValueProviderResult)

Sets the value for the specified key by using the specified value provider dictionary.

TryGetValue(String, ModelState) TryGetValue(String, ModelState) TryGetValue(String, ModelState)

Attempts to gets the value that is associated with the specified key.

Explicit Interface Implementations

IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator()

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

Applies to