ProfileAutoSaveEventHandler Delegate
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Represents the method that will handle the ProfileAutoSaving event of a ProfileModule.
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
The ProfileModule that raised the ProfileAutoSaving event.
A ProfileAutoSaveEventArgs that contains the event data.
The following code example shows the ProfileAutoSaving event included in the Global.asax file for an ASP.NET application.
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
The ProfileAutoSaveEventHandler delegate is defined for the ProfileAutoSaving event of the ProfileModule class. You can access the ProfileAutoSaving event of the ProfileModule class in the Global.asax file for your ASP.NET application, as shown in the example for this topic. The ProfileAutoSaving event is raised at the end of page execution if the AutomaticSaveEnabled property is true
.
The Save method automatically determines whether properties that are made up of primitive types, strings, or DateTime objects have been changed, by checking the IsDirty property value for each SettingsPropertyValue in the user profile. However, the Save method cannot explicitly determine whether a custom class has changed. You can handle the ProfileAutoSaving event to determine whether a custom object has been modified and to continue with the automatic save for modified objects and 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, regardless of whether you are canceling or continuing with the automatic save, as you may need to overwrite the value set by an earlier subscriber.
Get |
Gets an object that represents the method represented by the specified delegate. |
Product | Versions |
---|---|
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: