473,396 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Addhandler help

UGH
I am adding image buttons dynamically and I need to add event handler when
the user clicks on one of those image buttons which will have different id
for reports.

Here is my code

LnkImage = New ImageButton()
LnkImage.ImageUrl = "~/printer.gif"
LnkImage.ID = "ib" & oArray(1, id)
AddHandler LnkImage.Command, AddressOf NewIbnCommandEvent()
cellItem.Controls.Add(LnkImage)

here is the handler

Private Sub NewIbnCommandEvent(ByVal sender As System.Object, ByVal e As
System.Web.UI.ImageClickEventArgs)
' Will do something here
Reponse.redirect(""~/appt.aspx?appt_id=" & LnkImage.ID")
End Sub

But I get this error message. Argument not specified for parameter 'e' of
'Private Sub NewIbnCommandEvent(sender As Object, e As
System.Web.UI.ImageClickEventArgs)'.

I do not know what to put in between the () AddHandler LnkImage.Command,
AddressOf NewIbnCommandEvent()

Thanks for any help.


Nov 18 '05 #1
7 4000

Hi,
Please remove the parenthesis in the AddHandler code for the eventhandler,
your code should be

AddHandler LnkImage.Command, AddressOf NewIbnCommandEvent

instead of

AddHandler LnkImage.Command, AddressOf NewIbnCommandEvent()

For more information take a look at the following microsoft link

http://msdn.microsoft.com/library/de...BSpec8_6_2.asp

Good Luck

--
Kumar Reddi
http://kumarreddi.blogspot.com

"UGH" <no****@noSPam.com> wrote in message
news:OB**************@TK2MSFTNGP11.phx.gbl...
I am adding image buttons dynamically and I need to add event handler when
the user clicks on one of those image buttons which will have different id
for reports.

Here is my code

LnkImage = New ImageButton()
LnkImage.ImageUrl = "~/printer.gif"
LnkImage.ID = "ib" & oArray(1, id)
AddHandler LnkImage.Command, AddressOf NewIbnCommandEvent()
cellItem.Controls.Add(LnkImage)

here is the handler

Private Sub NewIbnCommandEvent(ByVal sender As System.Object, ByVal e As
System.Web.UI.ImageClickEventArgs)
' Will do something here
Reponse.redirect(""~/appt.aspx?appt_id=" & LnkImage.ID")
End Sub

But I get this error message. Argument not specified for parameter 'e' of
'Private Sub NewIbnCommandEvent(sender As Object, e As
System.Web.UI.ImageClickEventArgs)'.

I do not know what to put in between the () AddHandler LnkImage.Command,
AddressOf NewIbnCommandEvent()

Thanks for any help.

Nov 18 '05 #2
Couple things,

first to get rid of the error, simply remove the () after the addressof, so
instead of:
AddHandler LnkImage.Command, AddressOf NewIbnCommandEvent()

do:
AddHandler LnkImage.Command, AddressOf NewIbnCommandEvent

simple, non?
Secondly, if you are going to use Command instead of Click (which you
probably want to in this case), your 2nd parameter needs to be of type
System.Web.UI.WEbControls.CommandEventArgs. ImageclickEventArgs is for the
click event
Lastly, consider using LnkImage.CommandArgument = "ib" & oArray(i,id) and
use e.commandArgument as your parameter in your redirect. This way LnkImage
doesn't have to be declared as a global property - simply scope it where you
create it and forget about it.

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"UGH" <no****@noSPam.com> wrote in message
news:OB**************@TK2MSFTNGP11.phx.gbl...
I am adding image buttons dynamically and I need to add event handler when
the user clicks on one of those image buttons which will have different id
for reports.

Here is my code

LnkImage = New ImageButton()
LnkImage.ImageUrl = "~/printer.gif"
LnkImage.ID = "ib" & oArray(1, id)
AddHandler LnkImage.Command, AddressOf NewIbnCommandEvent()
cellItem.Controls.Add(LnkImage)

here is the handler

Private Sub NewIbnCommandEvent(ByVal sender As System.Object, ByVal e As
System.Web.UI.ImageClickEventArgs)
' Will do something here
Reponse.redirect(""~/appt.aspx?appt_id=" & LnkImage.ID")
End Sub

But I get this error message. Argument not specified for parameter 'e' of
'Private Sub NewIbnCommandEvent(sender As Object, e As
System.Web.UI.ImageClickEventArgs)'.

I do not know what to put in between the () AddHandler LnkImage.Command,
AddressOf NewIbnCommandEvent()

Thanks for any help.

Nov 18 '05 #3
UGH
I otok out the () but it still gives me the error.

XXXXXXX.aspx.vb(218): Method 'Private Sub NewIbnCommandEvent()' does not
have the same signature as delegate 'Delegate Sub CommandEventHandler(sender
As Object, e As System.Web.UI.WebControls.CommandEventArgs)'.

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl...
Couple things,

first to get rid of the error, simply remove the () after the addressof,
so
instead of:
AddHandler LnkImage.Command, AddressOf NewIbnCommandEvent()

do:
AddHandler LnkImage.Command, AddressOf NewIbnCommandEvent

simple, non?
Secondly, if you are going to use Command instead of Click (which you
probably want to in this case), your 2nd parameter needs to be of type
System.Web.UI.WEbControls.CommandEventArgs. ImageclickEventArgs is for the
click event
Lastly, consider using LnkImage.CommandArgument = "ib" & oArray(i,id) and
use e.commandArgument as your parameter in your redirect. This way
LnkImage
doesn't have to be declared as a global property - simply scope it where
you
create it and forget about it.

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"UGH" <no****@noSPam.com> wrote in message
news:OB**************@TK2MSFTNGP11.phx.gbl...
I am adding image buttons dynamically and I need to add event handler
when
the user clicks on one of those image buttons which will have different
id
for reports.

Here is my code

LnkImage = New ImageButton()
LnkImage.ImageUrl = "~/printer.gif"
LnkImage.ID = "ib" & oArray(1, id)
AddHandler LnkImage.Command, AddressOf NewIbnCommandEvent()
cellItem.Controls.Add(LnkImage)

here is the handler

Private Sub NewIbnCommandEvent(ByVal sender As System.Object, ByVal e As
System.Web.UI.ImageClickEventArgs)
' Will do something here
Reponse.redirect(""~/appt.aspx?appt_id=" & LnkImage.ID")
End Sub

But I get this error message. Argument not specified for parameter 'e' of
'Private Sub NewIbnCommandEvent(sender As Object, e As
System.Web.UI.ImageClickEventArgs)'.

I do not know what to put in between the () AddHandler LnkImage.Command,
AddressOf NewIbnCommandEvent()

Thanks for any help.


Nov 18 '05 #4
If you read my original reply, you'll see that I addressed this...it's my
second point.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"UGH" <no****@noSPam.com> wrote in message
news:uq**************@TK2MSFTNGP11.phx.gbl...
I otok out the () but it still gives me the error.

XXXXXXX.aspx.vb(218): Method 'Private Sub NewIbnCommandEvent()' does not
have the same signature as delegate 'Delegate Sub CommandEventHandler(sender As Object, e As System.Web.UI.WebControls.CommandEventArgs)'.

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl...
Couple things,

first to get rid of the error, simply remove the () after the addressof,
so
instead of:
AddHandler LnkImage.Command, AddressOf NewIbnCommandEvent()

do:
AddHandler LnkImage.Command, AddressOf NewIbnCommandEvent

simple, non?
Secondly, if you are going to use Command instead of Click (which you
probably want to in this case), your 2nd parameter needs to be of type
System.Web.UI.WEbControls.CommandEventArgs. ImageclickEventArgs is for the click event
Lastly, consider using LnkImage.CommandArgument = "ib" & oArray(i,id) and use e.commandArgument as your parameter in your redirect. This way
LnkImage
doesn't have to be declared as a global property - simply scope it where
you
create it and forget about it.

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"UGH" <no****@noSPam.com> wrote in message
news:OB**************@TK2MSFTNGP11.phx.gbl...
I am adding image buttons dynamically and I need to add event handler
when
the user clicks on one of those image buttons which will have different
id
for reports.

Here is my code

LnkImage = New ImageButton()
LnkImage.ImageUrl = "~/printer.gif"
LnkImage.ID = "ib" & oArray(1, id)
AddHandler LnkImage.Command, AddressOf NewIbnCommandEvent()
cellItem.Controls.Add(LnkImage)

here is the handler

Private Sub NewIbnCommandEvent(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs)
' Will do something here
Reponse.redirect(""~/appt.aspx?appt_id=" & LnkImage.ID")
End Sub

But I get this error message. Argument not specified for parameter 'e' of 'Private Sub NewIbnCommandEvent(sender As Object, e As
System.Web.UI.ImageClickEventArgs)'.

I do not know what to put in between the () AddHandler LnkImage.Command, AddressOf NewIbnCommandEvent()

Thanks for any help.



Nov 18 '05 #5
UGH
It is not clear to me but I figured out what you meant however the handler
that I added does not fired when I click on the button.

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl...
If you read my original reply, you'll see that I addressed this...it's my
second point.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"UGH" <no****@noSPam.com> wrote in message
news:uq**************@TK2MSFTNGP11.phx.gbl...
I otok out the () but it still gives me the error.

XXXXXXX.aspx.vb(218): Method 'Private Sub NewIbnCommandEvent()' does not
have the same signature as delegate 'Delegate Sub

CommandEventHandler(sender
As Object, e As System.Web.UI.WebControls.CommandEventArgs)'.

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl...
> Couple things,
>
> first to get rid of the error, simply remove the () after the
> addressof,
> so
> instead of:
> AddHandler LnkImage.Command, AddressOf NewIbnCommandEvent()
>
> do:
> AddHandler LnkImage.Command, AddressOf NewIbnCommandEvent
>
> simple, non?
>
>
> Secondly, if you are going to use Command instead of Click (which you
> probably want to in this case), your 2nd parameter needs to be of type
> System.Web.UI.WEbControls.CommandEventArgs. ImageclickEventArgs is for the > click event
>
>
> Lastly, consider using LnkImage.CommandArgument = "ib" & oArray(i,id) and > use e.commandArgument as your parameter in your redirect. This way
> LnkImage
> doesn't have to be declared as a global property - simply scope it
> where
> you
> create it and forget about it.
>
> Karl
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/
>
>
> "UGH" <no****@noSPam.com> wrote in message
> news:OB**************@TK2MSFTNGP11.phx.gbl...
>> I am adding image buttons dynamically and I need to add event handler
>> when
>> the user clicks on one of those image buttons which will have
>> different
>> id
>> for reports.
>>
>> Here is my code
>>
>> LnkImage = New ImageButton()
>> LnkImage.ImageUrl = "~/printer.gif"
>> LnkImage.ID = "ib" & oArray(1, id)
>> AddHandler LnkImage.Command, AddressOf NewIbnCommandEvent()
>> cellItem.Controls.Add(LnkImage)
>>
>> here is the handler
>>
>> Private Sub NewIbnCommandEvent(ByVal sender As System.Object, ByVal e As >> System.Web.UI.ImageClickEventArgs)
>> ' Will do something here
>> Reponse.redirect(""~/appt.aspx?appt_id=" & LnkImage.ID")
>> End Sub
>>
>> But I get this error message. Argument not specified for parameter 'e' of >> 'Private Sub NewIbnCommandEvent(sender As Object, e As
>> System.Web.UI.ImageClickEventArgs)'.
>>
>> I do not know what to put in between the () AddHandler LnkImage.Command, >> AddressOf NewIbnCommandEvent()
>>
>> Thanks for any help.
>>
>>
>>
>>
>
>



Nov 18 '05 #6
The linkimage must be added on postback and must have the handler hooked
then. In other words you CAN'T wrap the code in a if not page.ispostback.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"UGH" <no****@noSPam.com> wrote in message
news:u$**************@TK2MSFTNGP11.phx.gbl...
It is not clear to me but I figured out what you meant however the handler
that I added does not fired when I click on the button.

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl...
If you read my original reply, you'll see that I addressed this...it's my second point.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"UGH" <no****@noSPam.com> wrote in message
news:uq**************@TK2MSFTNGP11.phx.gbl...
I otok out the () but it still gives me the error.

XXXXXXX.aspx.vb(218): Method 'Private Sub NewIbnCommandEvent()' does not have the same signature as delegate 'Delegate Sub

CommandEventHandler(sender
As Object, e As System.Web.UI.WebControls.CommandEventArgs)'.

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl...
> Couple things,
>
> first to get rid of the error, simply remove the () after the
> addressof,
> so
> instead of:
> AddHandler LnkImage.Command, AddressOf NewIbnCommandEvent()
>
> do:
> AddHandler LnkImage.Command, AddressOf NewIbnCommandEvent
>
> simple, non?
>
>
> Secondly, if you are going to use Command instead of Click (which you
> probably want to in this case), your 2nd parameter needs to be of type > System.Web.UI.WEbControls.CommandEventArgs. ImageclickEventArgs is for
the
> click event
>
>
> Lastly, consider using LnkImage.CommandArgument = "ib" & oArray(i,id)

and
> use e.commandArgument as your parameter in your redirect. This way
> LnkImage
> doesn't have to be declared as a global property - simply scope it
> where
> you
> create it and forget about it.
>
> Karl
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/
>
>
> "UGH" <no****@noSPam.com> wrote in message
> news:OB**************@TK2MSFTNGP11.phx.gbl...
>> I am adding image buttons dynamically and I need to add event
handler >> when
>> the user clicks on one of those image buttons which will have
>> different
>> id
>> for reports.
>>
>> Here is my code
>>
>> LnkImage = New ImageButton()
>> LnkImage.ImageUrl = "~/printer.gif"
>> LnkImage.ID = "ib" & oArray(1, id)
>> AddHandler LnkImage.Command, AddressOf NewIbnCommandEvent()
>> cellItem.Controls.Add(LnkImage)
>>
>> here is the handler
>>
>> Private Sub NewIbnCommandEvent(ByVal sender As System.Object, ByVal

e As
>> System.Web.UI.ImageClickEventArgs)
>> ' Will do something here
>> Reponse.redirect(""~/appt.aspx?appt_id=" & LnkImage.ID")
>> End Sub
>>
>> But I get this error message. Argument not specified for parameter
'e' of
>> 'Private Sub NewIbnCommandEvent(sender As Object, e As
>> System.Web.UI.ImageClickEventArgs)'.
>>
>> I do not know what to put in between the () AddHandler

LnkImage.Command,
>> AddressOf NewIbnCommandEvent()
>>
>> Thanks for any help.
>>
>>
>>
>>
>
>



Nov 18 '05 #7
UGH
got it, wow this was a little tuff for me to grasp.
Thanks

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2***************@TK2MSFTNGP12.phx.gbl...
The linkimage must be added on postback and must have the handler hooked
then. In other words you CAN'T wrap the code in a if not page.ispostback.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"UGH" <no****@noSPam.com> wrote in message
news:u$**************@TK2MSFTNGP11.phx.gbl...
It is not clear to me but I figured out what you meant however the
handler
that I added does not fired when I click on the button.

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl...
> If you read my original reply, you'll see that I addressed this...it's my > second point.
>
> Karl
>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/
>
>
> "UGH" <no****@noSPam.com> wrote in message
> news:uq**************@TK2MSFTNGP11.phx.gbl...
>> I otok out the () but it still gives me the error.
>>
>> XXXXXXX.aspx.vb(218): Method 'Private Sub NewIbnCommandEvent()' does not >> have the same signature as delegate 'Delegate Sub
> CommandEventHandler(sender
>> As Object, e As System.Web.UI.WebControls.CommandEventArgs)'.
>>
>>
>>
>> "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
>> net>
>> wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl...
>> > Couple things,
>> >
>> > first to get rid of the error, simply remove the () after the
>> > addressof,
>> > so
>> > instead of:
>> > AddHandler LnkImage.Command, AddressOf NewIbnCommandEvent()
>> >
>> > do:
>> > AddHandler LnkImage.Command, AddressOf NewIbnCommandEvent
>> >
>> > simple, non?
>> >
>> >
>> > Secondly, if you are going to use Command instead of Click (which
>> > you
>> > probably want to in this case), your 2nd parameter needs to be of type >> > System.Web.UI.WEbControls.CommandEventArgs. ImageclickEventArgs is for > the
>> > click event
>> >
>> >
>> > Lastly, consider using LnkImage.CommandArgument = "ib" &
>> > oArray(i,id)
> and
>> > use e.commandArgument as your parameter in your redirect. This way
>> > LnkImage
>> > doesn't have to be declared as a global property - simply scope it
>> > where
>> > you
>> > create it and forget about it.
>> >
>> > Karl
>> > --
>> > MY ASP.Net tutorials
>> > http://www.openmymind.net/
>> >
>> >
>> > "UGH" <no****@noSPam.com> wrote in message
>> > news:OB**************@TK2MSFTNGP11.phx.gbl...
>> >> I am adding image buttons dynamically and I need to add event handler >> >> when
>> >> the user clicks on one of those image buttons which will have
>> >> different
>> >> id
>> >> for reports.
>> >>
>> >> Here is my code
>> >>
>> >> LnkImage = New ImageButton()
>> >> LnkImage.ImageUrl = "~/printer.gif"
>> >> LnkImage.ID = "ib" & oArray(1, id)
>> >> AddHandler LnkImage.Command, AddressOf NewIbnCommandEvent()
>> >> cellItem.Controls.Add(LnkImage)
>> >>
>> >> here is the handler
>> >>
>> >> Private Sub NewIbnCommandEvent(ByVal sender As System.Object, ByVal e > As
>> >> System.Web.UI.ImageClickEventArgs)
>> >> ' Will do something here
>> >> Reponse.redirect(""~/appt.aspx?appt_id=" & LnkImage.ID")
>> >> End Sub
>> >>
>> >> But I get this error message. Argument not specified for parameter 'e' > of
>> >> 'Private Sub NewIbnCommandEvent(sender As Object, e As
>> >> System.Web.UI.ImageClickEventArgs)'.
>> >>
>> >> I do not know what to put in between the () AddHandler
> LnkImage.Command,
>> >> AddressOf NewIbnCommandEvent()
>> >>
>> >> Thanks for any help.
>> >>
>> >>
>> >>
>> >>
>> >
>> >
>>
>>
>
>



Nov 18 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jeffrey A. Voigt | last post by:
Can someone take a quick glace at my code and tell me why my AutoPostBackHandler function does not get fired off at all? What I'm trying to do is get all of the Buttons and DropDownList controls...
4
by: DJ | last post by:
Good morning, Still new at this so please bear with me. I am creating a table dynamically using webcontrols based on the output of a sproc from my database.The table represents test instances...
2
by: MLS | last post by:
The documentation on dynamic handlers comes across as abiguous. Perhaps somebody could help set me straight? I have a situation where I need to dynamically create several usercontrols of the...
2
by: Just Me | last post by:
When a document is to be printed I call a method that contains an AddHandler statement. I just realized that if a second copy is to be printed the method is called and the AddHandler is executed...
5
by: eBob.com | last post by:
I've used AddHandler for a UNIQUE control added to a panel and it seemed to work. But now I want to add a bunch of controls to a panel and use only one event handler subroutine. And I am...
2
by: TrtnJohn | last post by:
If you call AddHandler and hook events of one object to a method in a class will the event source object still be available for garbage collection if the original reference is set to Nothing? Or...
5
by: Slim | last post by:
i have a simple page, with one button button1. when click it creates a new button button 2 and adds a event handler to it. but when button 2 is clicked nothing happens, why? Partial Class...
5
by: ugavnholt | last post by:
Hi All, I'm having a problem with a small bit of code: Dim deleteButton = New System.Web.UI.WebControls.ImageButton deleteButton.imageURL = "images/icondelete.gif" deleteButton.ToolTip =...
2
by: GS | last post by:
according to help Dim Obj As New Class1 ' Associate an event handler with an event. AddHandler Obj.Ev_Event, AddressOf EventHandler is the way to go, so I tried oBook = oExcel.Workbooks.Add '...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.