Custom Event Arguments
page 1 of 3
Published: 08 Sep 2002
Unedited - Community Contributed
Abstract
You've probably seen custom event arguments in use, probably in the DataGrid section of ASP.NET. Custom event arguments allow you to create a class that you pass along with your events that contain extra information in them that you may want.
by . .
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 18641/ 26

Introduction
Introduction

You've probably seen custom event arguments in use, probably in the DataGrid section of ASP.NET. Custom event arguments (from now on abbreviated to eventargs) allow you to create a class that you pass along with your events that contain extra information in them that you may want. The DataGridCommandEventArgs contains masses of information about the DataGrid and lets you manipulate it through it. Although I won't be showing you how to do that, this article will show you the basics of setting up some custom eventargs and implementing them.

What are they?

Just incase you are unsure what I'm taking about, custom eventargs are just a replacement (usually inherited from EventArgs) for the normal EventArgs on event handlers.

eg. Instead of -

Sub MyEventHandler(ByVal sender As Object, ByVal e As EventArgs)

You would use -

Sub MyEventHandler(ByVal sender As Object, ByVal e As CustomEventArgs)

Why use them?

If you check out my article on HTTPModules then you will see that I use them for sending the name of the browser to the event handler. If you have an event handler and you need to pass a lot of information (eg. Information about a user - Name, Address, Username, password, etc.) then this is the way.

The standard EventArgs can really only be passed in as EventArgs.Empty ie. empty. However, the class is there for you to be able to inherit from instead.

 


View Entire Article

User Comments

No comments posted yet.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-20 6:09:38 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search