One Sub, Multiple event Handlers

Posted on 2006-04-03
Last Modified: 2008-03-06
Heres what I have:

Sub ItemsGet(Optional ByVal sender As Object = Nothing, Optional ByVal e As EventArgs = Nothing) Handles search_button.Click, cmdPrev.Click, cmdPrev.Click

Is this even possible? If so, am I doing it right?
And - further  - if it is possible, how can I retrieve exactly which button was pressed.
I tried Response.Write(sender.ToString) but that wasnt useful, it just printed "System...Button"
Question by:EchoBinary
    1 Comment
    LVL 9

    Accepted Solution

    convert the sender object to button, e.g:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button2.Click, Button3.Click
          Label1.Text = CType(sender, Button).Text
    End Sub


    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now