ProfileAutoSaveEventArgs 类

定义

ProfileAutoSaving 类的 ProfileModule 事件提供数据。

public ref class ProfileAutoSaveEventArgs sealed : EventArgs
public sealed class ProfileAutoSaveEventArgs : EventArgs
type ProfileAutoSaveEventArgs = class
    inherit EventArgs
Public NotInheritable Class ProfileAutoSaveEventArgs
Inherits EventArgs
继承
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如果 ProfileManager.AutomaticSaveEnabled 属性为 true,则会在页面执行结束时引发 该事件。

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

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

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

构造函数

ProfileAutoSaveEventArgs(HttpContext)

创建 ProfileAutoSaveEventArgs 类的实例。

属性

Context

获取当前请求的 HttpContext

ContinueWithProfileAutoSave

获取或设置一个值,该值指示 ProfileModule 是否将自动保存用户配置文件。

方法

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ToString()

返回表示当前对象的字符串。

(继承自 Object)

适用于

另请参阅