ProfileAutoSaveEventHandler 委托    
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示将用来处理 ProfileAutoSaving 的 ProfileModule 事件的方法。
public delegate void ProfileAutoSaveEventHandler(System::Object ^ sender, ProfileAutoSaveEventArgs ^ e);public delegate void ProfileAutoSaveEventHandler(object sender, ProfileAutoSaveEventArgs e);type ProfileAutoSaveEventHandler = delegate of obj * ProfileAutoSaveEventArgs -> unitPublic Delegate Sub ProfileAutoSaveEventHandler(sender As Object, e As ProfileAutoSaveEventArgs)参数
- sender
- Object
引发 ProfileModule 事件的 ProfileAutoSaving。
包含事件数据的 ProfileAutoSaveEventArgs。
示例
下面的代码示例演示 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。
事件可能有多个订阅者 ProfileAutoSaving 。 ProfileModule将使用属性设置为的最后一个值ContinueWithProfileAutoSave。 因此,无论取消还是继续自动保存,都建议在 事件中ProfileAutoSaving显式设置 ContinueWithProfileAutoSave 属性,因为可能需要覆盖早期订阅者设置的值。
扩展方法
| GetMethodInfo(Delegate) | 获取指示指定委托表示的方法的对象。 |