HtmlHelper.ValidationMessage Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
ValidationMessage(String) |
Returns an HTML span element that contains the first validation error message for the specified form field. |
ValidationMessage(String, IDictionary<String,Object>) |
Returns an HTML span element that has the specified custom attributes defined by an attribute dictionary, and that contains the first validation error message for the specified form field. |
ValidationMessage(String, Object) |
Returns an HTML span element that has the specified custom attributes defined by an attribute object, and that contains the first validation error message for the specified form field. |
ValidationMessage(String, String) |
Returns an HTML span element that contains a validation error message for the specified form field. |
ValidationMessage(String, String, IDictionary<String,Object>) |
Returns an HTML span element that has the specified custom attributes defined by an attribute dictionary, and that contains a validation error message for the specified form field. |
ValidationMessage(String, String, Object) |
Returns an HTML span element that has the specified custom attributes defined by an attribute object, and that contains a validation error message for the specified form field. |
ValidationMessage(String)
Returns an HTML span element that contains the first validation error message for the specified form field.
public System.Web.IHtmlString ValidationMessage(string name);
member this.ValidationMessage : string -> System.Web.IHtmlString
Public Function ValidationMessage (name As String) As IHtmlString
Parameters
- name
- String
The name of the form field that was validated.
Returns
If the value in the specified field is valid, null; otherwise, the HTML markup that represents the validation error message that is associated with the specified field.
Exceptions
name
is null or empty.
Applies to
ValidationMessage(String, IDictionary<String,Object>)
Returns an HTML span element that has the specified custom attributes defined by an attribute dictionary, and that contains the first validation error message for the specified form field.
public System.Web.IHtmlString ValidationMessage(string name, System.Collections.Generic.IDictionary<string,object> htmlAttributes);
member this.ValidationMessage : string * System.Collections.Generic.IDictionary<string, obj> -> System.Web.IHtmlString
Public Function ValidationMessage (name As String, htmlAttributes As IDictionary(Of String, Object)) As IHtmlString
Parameters
- name
- String
The name of the form field that was validated.
- htmlAttributes
- IDictionary<String,Object>
The names and values of custom attributes for the element.
Returns
If the value in the specified field is valid, null; otherwise, the HTML markup that represents the validation error message that is associated with the specified field.
Exceptions
name
is null or empty.
Applies to
ValidationMessage(String, Object)
Returns an HTML span element that has the specified custom attributes defined by an attribute object, and that contains the first validation error message for the specified form field.
public System.Web.IHtmlString ValidationMessage(string name, object htmlAttributes);
member this.ValidationMessage : string * obj -> System.Web.IHtmlString
Public Function ValidationMessage (name As String, htmlAttributes As Object) As IHtmlString
Parameters
- name
- String
The name of the form field that was validated.
- htmlAttributes
- Object
An object that contains custom attributes for the element. The attribute names and values are retrieved through reflection by examining the properties of the object.
Returns
If the value in the specified field is valid, null; otherwise, the HTML markup that represents the validation error message that is associated with the specified field.
Exceptions
name
is null or empty.
Applies to
ValidationMessage(String, String)
Returns an HTML span element that contains a validation error message for the specified form field.
public System.Web.IHtmlString ValidationMessage(string name, string message);
member this.ValidationMessage : string * string -> System.Web.IHtmlString
Public Function ValidationMessage (name As String, message As String) As IHtmlString
Parameters
- name
- String
The name of the form field that was validated.
- message
- String
The validation error message to display. If null, the first validation error message that is associated with the specified form field is displayed.
Returns
If the value in the specified field is valid, null; otherwise, the HTML markup that represents the validation error message that is associated with the specified field.
Exceptions
name
is null or empty.
Applies to
ValidationMessage(String, String, IDictionary<String,Object>)
Returns an HTML span element that has the specified custom attributes defined by an attribute dictionary, and that contains a validation error message for the specified form field.
public System.Web.IHtmlString ValidationMessage(string name, string message, System.Collections.Generic.IDictionary<string,object> htmlAttributes);
member this.ValidationMessage : string * string * System.Collections.Generic.IDictionary<string, obj> -> System.Web.IHtmlString
Public Function ValidationMessage (name As String, message As String, htmlAttributes As IDictionary(Of String, Object)) As IHtmlString
Parameters
- name
- String
The name of the form field that was validated.
- message
- String
The validation error message to display. If null, the first validation error message that is associated with the specified form field is displayed.
- htmlAttributes
- IDictionary<String,Object>
The names and values of custom attributes for the element.
Returns
If the specified field is valid, null; otherwise, the HTML markup that represents a validation error message that is associated with the specified field.
Exceptions
name
is null or empty.
Applies to
ValidationMessage(String, String, Object)
Returns an HTML span element that has the specified custom attributes defined by an attribute object, and that contains a validation error message for the specified form field.
public System.Web.IHtmlString ValidationMessage(string name, string message, object htmlAttributes);
member this.ValidationMessage : string * string * obj -> System.Web.IHtmlString
Public Function ValidationMessage (name As String, message As String, htmlAttributes As Object) As IHtmlString
Parameters
- name
- String
The name of the form field that was validated.
- message
- String
The validation error message to display. If null, the first validation error message that is associated with the specified form field is displayed.
- htmlAttributes
- Object
An object that contains custom attributes for the element. The attribute names and values are retrieved through reflection by examining the properties of the object.
Returns
If the specified field is valid, null; otherwise, the HTML markup that represents a validation error message that is associated with the specified field.
Exceptions
name
is null or empty.