Last post Feb 16, 2009 10:19 AM by Talis
Feb 15, 2009 11:09 AM|Talis|LINK
In a BeerHouse website, I made a shopping cart a little different from the original one : the shoppingcart is not cleared after the order is passed (I won't explain why we did that but it feets our needs...).
I just deleted the line : "Me.Profile.ShoppingCart.Clear()" in the ShoppingCart.aspx code behind page.
Accordingly, the storekeeper should be able to clear all the shopping carts at a time (from an admin page, just clicking on a button).
Private allProfiles As ProfileInfoCollection = ProfileManager.GetAllProfiles(ProfileAuthenticationOption.All)
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
For Each info As ProfileInfo In allProfiles
Dim userProfile As ProfileCommon = Profile.GetProfile(info.UserName)
Running this code, no error appears but the shopping carts are not cleared...
Can anyone see what the problem is ?
Feb 15, 2009 06:07 PM|Lee Dumond|LINK
Most of the time, when a profile property changes, ASP.NET can detect this and will save the profile automatically.
But this detection mechanism usually only works with simple types, like integers and strings. Sometimes when working with complex custom types (Like a ShoppingCart), ASP.NET has no reliable way of knowing when the property "changes". This means you might
have to call the Save() method explicitly on each profile after clearing the shopping cart.
This is just off the top of my head, mind you. Give it a go and let us know if it worked.
Feb 16, 2009 10:19 AM|Talis|LINK
You are right, it works fine now !
I would never have imagined that because in the ShoppingCart.aspx code behind the Save() method is not used after clearing the shopping cart...
Thanks a lot for your help, Lee.