ValidatingPropertiesEventArgs.Properties 屬性

定義

取得要驗證的設定檔屬性名稱和值的集合。

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)

屬性值

要驗證的設定檔屬性名稱和值。

範例

下列範例顯示 事件的事件處理常式 ValidatingProperties 。 當針對 屬性傳遞 FirstName 的值是空的 或 null 時,屬性 FirstName 就會加入集合 FailedProperties 中。

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

備註

屬性 PropertiesIDictionary 傳回 物件,其中包含要為使用者設定之配置檔案屬性的名稱和值。 如果您為 ValidatingProperties 事件建立事件處理常式,您可以從 屬性擷取要驗證 Properties 的屬性。 如果有任何值驗證失敗,請將這些值新增至 FailedProperties 屬性。 方法 SetPropertiesForCurrentUser 會傳回 屬性中的 FailedProperties 集合,以便判斷哪些屬性驗證失敗。

適用於