Editare

Partajați prin


ValidationContext.MemberName Property

Definition

Gets or sets the name of the member to validate.

public:
 property System::String ^ MemberName { System::String ^ get(); void set(System::String ^ value); };
public string MemberName { get; set; }
public string? MemberName { get; set; }
member this.MemberName : string with get, set
Public Property MemberName As String

Property Value

The name of the member to validate.

Remarks

This property represents an entity member name, not the name of a corresponding data field. Therefore, this name is not localized. It should be set only for property or parameter contexts.

In .NET Framework 4.7.2 and earlier versions, when using a custom System.ComponentModel.DataAnnotations.ValidationAttribute, the MemberName property returns null. Starting with .NET Framework October 2019 Preview of Quality Rollup for .NET Framework 4.8, the property returns the member name if you add the following setting to your web.config file:

<configuration>
   <appSettings>
      <add key="aspnet:GetValidationMemberName" value="true" />
   </appSettings>
</configuration>

Without this setting, this property returns null with .NET Framework October 2019 Preview of Quality Rollup or later versions.

In .NET Framework 4.8 version prior to the October 2019 update, this property returns member name without the configuration setting. If you change your web.config file as shown in the previous example, the property returns null.

Applies to