Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
ProfileModule Class
 ProfileAutoSaving Event

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
ProfileModule..::.ProfileAutoSaving Event

Occurs at the end of page execution if automatic profile saving is enabled.

Namespace:  System.Web.Profile
Assembly:  System.Web (in System.Web.dll)
Visual Basic (Declaration)
Public Event ProfileAutoSaving As ProfileAutoSaveEventHandler
Visual Basic (Usage)
Dim instance As ProfileModule
Dim handler As ProfileAutoSaveEventHandler

AddHandler instance.ProfileAutoSaving, handler
C#
public event ProfileAutoSaveEventHandler ProfileAutoSaving
Visual C++
public:
 event ProfileAutoSaveEventHandler^ ProfileAutoSaving {
    void add (ProfileAutoSaveEventHandler^ value);
    void remove (ProfileAutoSaveEventHandler^ value);
}
JScript
JScript does not support events.

The ProfileAutoSaving event is raised at the end of page execution if the ProfileManager..::.AutomaticSaveEnabled property is true. You can access the ProfileAutoSaving event of the ProfileModule class in the Global.asax file for your ASP.NET application using the Profile_ProfileAutoSaving global event, as shown in the example for this topic.

The SettingsBase..::.Save method checks the IsDirty property value for each SettingsPropertyValue in the user profile to determine whether properties that are made up of primitive types, strings, or DateTime objects have been changed. The Save method cannot explicitly determine whether a custom class has changed. You can use the ProfileAutoSaving event to determine whether a custom object has been changed and then either to continue with the automatic save for modified objects or to cancel the automatic save if no objects have been modified.

To cancel the automatic profile save operation, set the ContinueWithProfileAutoSave property to false in the ProfileAutoSaving event; otherwise, set the ContinueWithProfileAutoSave property to true.

There may be multiple subscribers to the ProfileAutoSaving event. The ProfileModule will use the last value that the ContinueWithProfileAutoSave property is set to. As a result, it is recommended that you explicitly set the ContinueWithProfileAutoSave property in the ProfileAutoSaving event whether you are canceling or continuing with the automatic save, as you may need to overwrite the value set by an earlier subscriber.

The following code example shows the ProfileAutoSaving event included in the Global.asax file for an ASP.NET application.

Visual Basic
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

C#
public void Profile_ProfileAutoSaving(object sender, ProfileAutoSaveEventArgs args)
{
  if (Profile.Cart.HasChanged)
    args.ContinueWithProfileAutoSave = true;
  else
    args.ContinueWithProfileAutoSave = false;
}

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker