|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Same function different signaturesI 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 Put all the logic that does the printing into its own function. Then call it
from both of the event handlers. Show quoteHide quote "tshad" <tscheider***@ftsolutions.com> wrote in message news:u%23cxAuceGHA.4304@TK2MSFTNGP05.phx.gbl... >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 > That's what I thought.
I was hoping to do it from one function. Thanks, Tom Show quoteHide quote "Marina Levit [MVP]" <someone@nospam.com> wrote in message news:OCbCX1ceGHA.3388@TK2MSFTNGP05.phx.gbl... > Put all the logic that does the printing into its own function. Then call > it from both of the event handlers. > > "tshad" <tscheider***@ftsolutions.com> wrote in message > news:u%23cxAuceGHA.4304@TK2MSFTNGP05.phx.gbl... >>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 >> > > 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. Show quoteHide quote "tshad" <tscheider***@ftsolutions.com> wrote in message news:ekRhgEdeGHA.1456@TK2MSFTNGP04.phx.gbl... > That's what I thought. > > I was hoping to do it from one function. > > Thanks, > > Tom > "Marina Levit [MVP]" <someone@nospam.com> wrote in message > news:OCbCX1ceGHA.3388@TK2MSFTNGP05.phx.gbl... >> Put all the logic that does the printing into its own function. Then call >> it from both of the event handlers. >> >> "tshad" <tscheider***@ftsolutions.com> wrote in message >> news:u%23cxAuceGHA.4304@TK2MSFTNGP05.phx.gbl... >>>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 >>> >> >> > > It doesn't really, I was just curious if I could.
And you're right about creating another method. Thanks, Tom Show quoteHide quote "Marina Levit [MVP]" <someone@nospam.com> wrote in message news:eeN4PadeGHA.3900@TK2MSFTNGP05.phx.gbl... > 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. > > "tshad" <tscheider***@ftsolutions.com> wrote in message > news:ekRhgEdeGHA.1456@TK2MSFTNGP04.phx.gbl... >> That's what I thought. >> >> I was hoping to do it from one function. >> >> Thanks, >> >> Tom >> "Marina Levit [MVP]" <someone@nospam.com> wrote in message >> news:OCbCX1ceGHA.3388@TK2MSFTNGP05.phx.gbl... >>> Put all the logic that does the printing into its own function. Then >>> call it from both of the event handlers. >>> >>> "tshad" <tscheider***@ftsolutions.com> wrote in message >>> news:u%23cxAuceGHA.4304@TK2MSFTNGP05.phx.gbl... >>>>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 >>>> >>> >>> >> >> > >
Other interesting topics
|
|||||||||||||||||||||||