Same function different signatures

Discussion in 'ASP .Net' started by tshad, May 17, 2006.

  1. tshad

    tshad Guest

    I have a function that I want to jump to from 2 different controls
    (ImageButton and LinkButton).

    The problem is I get the error:

    Method 'Public Sub PrintPage_Click(sender As Object, e As
    System.Web.UI.ImageClickEventArgs)' does not have the same signature as
    delegate 'Delegate Sub EventHandler(sender As Object, e As System.EventArgs)

    Is there a way to call the same function from these 2 buttons?

    Thanks,

    Tom
     
    tshad, May 17, 2006
    #1
    1. Advertisements

  2. Put all the logic that does the printing into its own function. Then call it
    from both of the event handlers.
     
    Marina Levit [MVP], May 17, 2006
    #2
    1. Advertisements

  3. tshad

    tshad Guest

    That's what I thought.

    I was hoping to do it from one function.

    Thanks,

    Tom
     
    tshad, May 17, 2006
    #3
  4. Why? Does it really matter?

    You could change the PrintPage_Click method to have just EventArgs as the
    second argument, which will be fine as long as you are not using any of the
    information in the arguments you have now.

    But in reality, it's not even worth doing. Creating another method is
    trivial.
     
    Marina Levit [MVP], May 17, 2006
    #4
  5. tshad

    tshad Guest

    It doesn't really, I was just curious if I could.

    And you're right about creating another method.

    Thanks,

    Tom
     
    tshad, May 17, 2006
    #5
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.