ProfileAutoSaveEventHandler 委托

定义

表示将用来处理 ProfileAutoSavingProfileModule 事件的方法。

public delegate void ProfileAutoSaveEventHandler(System::Object ^ sender, ProfileAutoSaveEventArgs ^ e);
public delegate void ProfileAutoSaveEventHandler(object sender, ProfileAutoSaveEventArgs e);
type ProfileAutoSaveEventHandler = delegate of obj * ProfileAutoSaveEventArgs -> unit
Public Delegate Sub ProfileAutoSaveEventHandler(sender As Object, e As ProfileAutoSaveEventArgs)

参数

sender
Object

引发 ProfileModule 事件的 ProfileAutoSaving

示例

下面的代码示例演示 ProfileAutoSaving ASP.NET 应用程序的 Global.asax 文件中包含的 事件。

public void Profile_ProfileAutoSaving(object sender, ProfileAutoSaveEventArgs args)
{
  if (Profile.Cart.HasChanged)
    args.ContinueWithProfileAutoSave = true;
  else
    args.ContinueWithProfileAutoSave = false;
}
Public Sub Profile_ProfileAutoSaving(sender As Object, args As ProfileAutoSaveEventArgs)
  If Profile.Cart.HasChanged Then
    args.ContinueWithProfileAutoSave = True
  Else
    args.ContinueWithProfileAutoSave = False
  End If
End Sub

注解

委托 ProfileAutoSaveEventHandler 是为 ProfileAutoSaving 类的 ProfileModule 事件定义的。 可以在 ASP.NET 应用程序的 Global.asax 文件中访问 ProfileAutoSaving 类的事件 ProfileModule ,如本主题的示例所示。 ProfileAutoSaving如果 AutomaticSaveEnabled 属性为 true,则会在页面执行结束时引发 该事件。

方法Save通过检查IsDirty用户配置文件中每个SettingsPropertyValue元素的属性值,自动确定由基元类型、字符串或DateTime对象组成的属性是否已更改。 但是, Save 方法无法显式确定自定义类是否已更改。 可以处理 ProfileAutoSaving 事件以确定自定义对象是否已修改,并继续自动保存已修改的对象,如果未修改任何对象,则取消自动保存。

若要取消自动配置文件保存操作,请在 ContinueWithProfileAutoSave 事件中ProfileAutoSaving将 属性设置为 false ;否则,将 ContinueWithProfileAutoSave 属性设置为 true

事件可能有多个订阅者 ProfileAutoSavingProfileModule将使用属性设置为的最后一个值ContinueWithProfileAutoSave。 因此,建议在 事件中ProfileAutoSaving显式设置 ContinueWithProfileAutoSave 属性,无论你是取消还是继续自动保存,因为可能需要覆盖早期订阅者设置的值。

扩展方法

GetMethodInfo(Delegate)

获取指示指定委托表示的方法的对象。

适用于

另请参阅