Calling Events from web page

  • Thread starter Thread starter Duckkiller
  • Start date Start date
D

Duckkiller

Could someone please help: I'm trying to understand how you would call
these two events from a web page. AnonymousIdentification_Creating and
Profile_MigrateAnonymous. The Author of the book I'm reading states that
they can be called from the web page's source.

I have included what the author of the book I'm reading states about
working with Anonymous Identification. I was able to get the
AnonymousIdentification_Creating to fire by simply placing it in the
Global.asax file. It worked and the AnonymousID changed. Is that because
the sub in Listing 15-15 is actually a delegate to an event? Also, the next
section talks about the Profile_MigrateAnonymous() event and that it can be
placed in the page that deals with the migration. How do you do get it to
fire. Everything that I have read on events states that you delcare and
event, you raise the event, and then you set a sub to be called when the
event fires using the 'Handles' clause. Or you can create a Delegate and
point that delegate to a method with a similar signature. But the below
explanation does not follow any of those rules. Any help would be greatly
appreaciated.

Any help would be greatly appreaciated

Thanks

Dave

****************************** From the book ******************************

In working with the creation of anonymous users, be aware of an important
event which you can use from your Global.asax file that can be used for
managing the process: AnonymousIdentification_Creating

By using the AnonymousIdentification_Creating event, you can work with the
identification of the end
user as it occurs. For instance, if you do not want to use GUIDs for
uniquely identifying the end user, you can change the identifying value from
this event instead.
To do so, create the event using the event delegate of type
AnonymousIdentificationEventArgs, as illustrated in Listing 15-15.


Listing 15-15:

Public Sub AnonymousIdentification_Creating(ByVal sender As Object, ByVal e
As AnonymousIDentificationEventArgs)
e.AnonymousID = "Anonymous test " & DateTime.Now()
End Sub


The Author Also states this about migrating Anonymous users using
Profile_MigrateAnonymous event handler.



When working with anonymous users, you must be able to migrate anonymous
users to registered users. for example, after an end user fills a shopping
cart, he can register on the site to purchase the items. At that moment,
the end users switches from being an anonymous user to a registered user.
For this reason, ASP.NET provides a Profile_MigrateAnonymoous event handler
enabling you to migrate anonymous users to registered users. The
profile_MigrateAnonymouseevent requires a data class of type
ProfileMigrateEventArgs. It is placed either in the page that deals with
the migration or within the Global.asax file (if it can be used from
anywhere within the application). The use of this event is illustrated in
Listing 15-17

Listing 15-17

Public Sub Profile_MigrateAnonymous(ByVal sender As Object, ByVal e As
ProfileMigrateEventArgs)


Dim anonymousProfile As ProfileCommon =
Profile.GetProfile(e.AnonymousID)
Profile.LastVisited = anonymousProfile.LastVisited


End Sub
 
Could someone please help: I'm trying to understand how you would
call these two events from a web page.
AnonymousIdentification_Creating and Profile_MigrateAnonymous. The
Author of the book I'm reading states that they can be called from the
web page's source.

he actually states, although not emphatically, that you can code them in
the global.asax file. It is the global handler for the application and
session.

These are events fired, and they need to be handled by a file that is
called as part of the normal ASP.NET process. The page is at a higher
level in the "stack", so to speak, so it cannot directly handle the
event, at leats not without a lot of kludging.

If you want to handle the event, you can do it in the global.asax file.
If you need to do something with it from the page, you will have to
store it where it can be pulled. Session might be an option, as you need
some separation of different anonymous calls. You can also create a
custom property bag, but it would have to be cleaned out over time, so
session is probably easiest. ;-)

Peace and Grace,
Greg

--
Vote for Miranda's Christmas Story
http://tinyurl.com/mirandabelieve

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
Back
Top