Partager via


ValidationExtensions.Validate Method

Retrieves the validation metadata for the specified model and applies each rule to the data field.

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

Syntax

'Declaration
<ExtensionAttribute> _
Public Shared Sub Validate ( _
    htmlHelper As HtmlHelper, _
    modelName As String _
)
public static void Validate(
    this HtmlHelper htmlHelper,
    string modelName
)
[ExtensionAttribute]
public:
static void Validate(
    HtmlHelper^ htmlHelper, 
    String^ modelName
)

Parameters

  • modelName
    Type: System.String
    The name of the property or model object that is being validated.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type HtmlHelper. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Exceptions

Exception Condition
ArgumentNullException

The modelName parameter is null reference (Nothing in Visual Basic).

Remarks

Client validation must be enabled.

See Also

Reference

ValidationExtensions Class

System.Web.Mvc.Html Namespace