Export (0) Print
Expand All

RequiredAttribute Constructor

Initializes a new instance of the RequiredAttribute class.

Namespace:  System.ComponentModel.DataAnnotations
Assemblies:   System.ComponentModel.DataAnnotations (in System.ComponentModel.DataAnnotations.dll)
  System.ComponentModel.Annotations (in System.ComponentModel.Annotations.dll)

public RequiredAttribute()

The following example shows how to use the RequiredAttribute constructor. If validation fails, the example displays a validation error message that is provided by Dynamic Data.

// Require that the MiddleName is not null. 
// Use standard validation error.
public object MiddleName;

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5 SP1

.NET Framework Client Profile

Supported in: 4

Portable Class Library

Supported in: Portable Class Library
© 2015 Microsoft