संपादित करें

इसके माध्यम से साझा किया गया


ValidatingPropertiesEventArgs.Properties Property

Definition

Gets the collection of names and values of the profile properties to validate.

public:
 property System::Collections::Generic::IDictionary<System::String ^, System::Object ^> ^ Properties { System::Collections::Generic::IDictionary<System::String ^, System::Object ^> ^ get(); };
public System.Collections.Generic.IDictionary<string,object> Properties { get; }
member this.Properties : System.Collections.Generic.IDictionary<string, obj>
Public ReadOnly Property Properties As IDictionary(Of String, Object)

Property Value

The names and values of the profile properties to validate.

Examples

The following example shows an event handler for the ValidatingProperties event. When the value passed for FirstName property is empty or null, the FirstName property is added to the FailedProperties collection.

void Application_Start(object sender, EventArgs e) 
{
    System.Web.ApplicationServices.ProfileService.ValidatingProperties += new EventHandler<System.Web.ApplicationServices.ValidatingPropertiesEventArgs>(ProfileService_ValidatingProperties);
}

void ProfileService_ValidatingProperties(object sender, System.Web.ApplicationServices.ValidatingPropertiesEventArgs e)
{
    if (String.IsNullOrEmpty((string)e.Properties["FirstName"]))
    {
        e.FailedProperties.Add("FirstName");
    }
}
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
    AddHandler System.Web.ApplicationServices.ProfileService.ValidatingProperties, _
      AddressOf ProfileService_ValidatingProperties
End Sub

Sub ProfileService_ValidatingProperties(ByVal sender As Object, ByVal e As System.Web.ApplicationServices.ValidatingPropertiesEventArgs)
    If (String.IsNullOrEmpty(CType(e.Properties("FirstName"), String))) Then
        e.FailedProperties.Add("FirstName")
    End If
End Sub

Remarks

The Properties property returns an IDictionary object that contains the names and values of the profile properties to set for the user. If you create an event handler for the ValidatingProperties event, you can retrieve the properties to validate from the Properties property. If any values fail validation, add them to the FailedProperties property. The SetPropertiesForCurrentUser method returns the collection in the FailedProperties property so that you can determine which properties failed validation.

Applies to