473,397 Members | 1,950 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,397 software developers and data experts.

Question about ImageButton Event

Dear all,

I know that i can add a button with oncommand event "ImageButton_Command" by
using the asp:ImageButton tag in the aspx code.

<asp:ImageButton id="imagebutton1" runat="server"
AlternateText="Sort Ascending"
ImageUrl="images/pict.jpg"
OnCommand="ImageButton_Command"
CommandName="Sort"
CommandArgument="Ascending"/>

But i have problem if i add that button in the codebehind,
Protected WithEvents imagebutton1As System.Web.UI.WebControls.ImageButton

ibtnSetup = New ImageButton

ibtnSetup.ImageUrl() = "icon-setup.gif"

ibtnSetup.CausesValidation = False

ibtnSetup.CommandArgument = drRack.Item("LOCATION_ID")

Protected Sub ibtnSetup_Click(ByVal sender As Object, ByVal e As
CommandEventArgs) Handles ibtnSetup.Command

Console.Write(e.CommandArgument)

End Sub
However, i cannot fire the event by adding the button in the codebehind,
what's wrong with that?

Thank you for your advices.

Regards,
Angus
Nov 18 '05 #1
4 1853
you need to add this event handler..

this.ImageButton1.Click += new
System.Web.UI.ImageClickEventHandler(this.ibtnSetu p_Click);

Av.

"angus" <an***@angus.com> wrote in message
news:eD**************@TK2MSFTNGP11.phx.gbl...
Dear all,

I know that i can add a button with oncommand event "ImageButton_Command"
by
using the asp:ImageButton tag in the aspx code.

<asp:ImageButton id="imagebutton1" runat="server"
AlternateText="Sort Ascending"
ImageUrl="images/pict.jpg"
OnCommand="ImageButton_Command"
CommandName="Sort"
CommandArgument="Ascending"/>

But i have problem if i add that button in the codebehind,
Protected WithEvents imagebutton1As System.Web.UI.WebControls.ImageButton

ibtnSetup = New ImageButton

ibtnSetup.ImageUrl() = "icon-setup.gif"

ibtnSetup.CausesValidation = False

ibtnSetup.CommandArgument = drRack.Item("LOCATION_ID")

Protected Sub ibtnSetup_Click(ByVal sender As Object, ByVal e As
CommandEventArgs) Handles ibtnSetup.Command

Console.Write(e.CommandArgument)

End Sub
However, i cannot fire the event by adding the button in the codebehind,
what's wrong with that?

Thank you for your advices.

Regards,
Angus

Nov 18 '05 #2
i am using VB.net
this.ImageButton1.Click += new
System.Web.UI.ImageClickEventHandler(this.ibtnSetu p_Click);
i know that i have to use above statement if i am using c#.

what if VB.net?
"avnrao" <av*@newsgroups.com> wrote in message
news:Oe**************@TK2MSFTNGP12.phx.gbl... you need to add this event handler..

this.ImageButton1.Click += new
System.Web.UI.ImageClickEventHandler(this.ibtnSetu p_Click);

Av.

"angus" <an***@angus.com> wrote in message
news:eD**************@TK2MSFTNGP11.phx.gbl...
Dear all,

I know that i can add a button with oncommand event "ImageButton_Command" by
using the asp:ImageButton tag in the aspx code.

<asp:ImageButton id="imagebutton1" runat="server"
AlternateText="Sort Ascending"
ImageUrl="images/pict.jpg"
OnCommand="ImageButton_Command"
CommandName="Sort"
CommandArgument="Ascending"/>

But i have problem if i add that button in the codebehind,
Protected WithEvents imagebutton1As System.Web.UI.WebControls.ImageButton
ibtnSetup = New ImageButton

ibtnSetup.ImageUrl() = "icon-setup.gif"

ibtnSetup.CausesValidation = False

ibtnSetup.CommandArgument = drRack.Item("LOCATION_ID")

Protected Sub ibtnSetup_Click(ByVal sender As Object, ByVal e As
CommandEventArgs) Handles ibtnSetup.Command

Console.Write(e.CommandArgument)

End Sub
However, i cannot fire the event by adding the button in the codebehind,
what's wrong with that?

Thank you for your advices.

Regards,
Angus


Nov 18 '05 #3
AddHandler ImageButton1.Click, AddressOf ibtnSetup_Click

Av.

"Harry" <ha******@mail.hongkong.com> wrote in message
news:eq**************@TK2MSFTNGP12.phx.gbl...
i am using VB.net
this.ImageButton1.Click += new
System.Web.UI.ImageClickEventHandler(this.ibtnSetu p_Click);


i know that i have to use above statement if i am using c#.

what if VB.net?
"avnrao" <av*@newsgroups.com> wrote in message
news:Oe**************@TK2MSFTNGP12.phx.gbl...
you need to add this event handler..

this.ImageButton1.Click += new
System.Web.UI.ImageClickEventHandler(this.ibtnSetu p_Click);

Av.

"angus" <an***@angus.com> wrote in message
news:eD**************@TK2MSFTNGP11.phx.gbl...
> Dear all,
>
> I know that i can add a button with oncommand event "ImageButton_Command" > by
> using the asp:ImageButton tag in the aspx code.
>
> <asp:ImageButton id="imagebutton1" runat="server"
> AlternateText="Sort Ascending"
> ImageUrl="images/pict.jpg"
> OnCommand="ImageButton_Command"
> CommandName="Sort"
> CommandArgument="Ascending"/>
>
> But i have problem if i add that button in the codebehind,
>
>
> Protected WithEvents imagebutton1As System.Web.UI.WebControls.ImageButton >
> ibtnSetup = New ImageButton
>
> ibtnSetup.ImageUrl() = "icon-setup.gif"
>
> ibtnSetup.CausesValidation = False
>
> ibtnSetup.CommandArgument = drRack.Item("LOCATION_ID")
>
> Protected Sub ibtnSetup_Click(ByVal sender As Object, ByVal e As
> CommandEventArgs) Handles ibtnSetup.Command
>
> Console.Write(e.CommandArgument)
>
> End Sub
>
>
> However, i cannot fire the event by adding the button in the
> codebehind,
> what's wrong with that?
>
> Thank you for your advices.
>
> Regards,
> Angus
>
>



Nov 18 '05 #4
got it....thank you so much.

"avnrao" <av*@newsgroups.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
AddHandler ImageButton1.Click, AddressOf ibtnSetup_Click

Av.

"Harry" <ha******@mail.hongkong.com> wrote in message
news:eq**************@TK2MSFTNGP12.phx.gbl...
i am using VB.net
this.ImageButton1.Click += new
System.Web.UI.ImageClickEventHandler(this.ibtnSetu p_Click);


i know that i have to use above statement if i am using c#.

what if VB.net?
"avnrao" <av*@newsgroups.com> wrote in message
news:Oe**************@TK2MSFTNGP12.phx.gbl...
you need to add this event handler..

this.ImageButton1.Click += new
System.Web.UI.ImageClickEventHandler(this.ibtnSetu p_Click);

Av.

"angus" <an***@angus.com> wrote in message
news:eD**************@TK2MSFTNGP11.phx.gbl...
> Dear all,
>
> I know that i can add a button with oncommand event

"ImageButton_Command"
> by
> using the asp:ImageButton tag in the aspx code.
>
> <asp:ImageButton id="imagebutton1" runat="server"
> AlternateText="Sort Ascending"
> ImageUrl="images/pict.jpg"
> OnCommand="ImageButton_Command"
> CommandName="Sort"
> CommandArgument="Ascending"/>
>
> But i have problem if i add that button in the codebehind,
>
>
> Protected WithEvents imagebutton1As

System.Web.UI.WebControls.ImageButton
>
> ibtnSetup = New ImageButton
>
> ibtnSetup.ImageUrl() = "icon-setup.gif"
>
> ibtnSetup.CausesValidation = False
>
> ibtnSetup.CommandArgument = drRack.Item("LOCATION_ID")
>
> Protected Sub ibtnSetup_Click(ByVal sender As Object, ByVal e As
> CommandEventArgs) Handles ibtnSetup.Command
>
> Console.Write(e.CommandArgument)
>
> End Sub
>
>
> However, i cannot fire the event by adding the button in the
> codebehind,
> what's wrong with that?
>
> Thank you for your advices.
>
> Regards,
> Angus
>
>



Nov 18 '05 #5

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

Similar topics

2
by: Chuck Hartman | last post by:
I've been trying to add an ImageButton object to a Calendar table cell, but so far I am unable to handle the Command event from that button in my form's code behind. Below is an example of what I...
5
by: J McD | last post by:
Hi I have a DataGrid with an ImageButton column. When I click on an imagebutton I get a postback but it doesn't run the OnImgBtnClick method. I can actually comment out the line where I add this...
1
by: Henke | last post by:
Hello, I have one ImageButton controls which I initialize in Page_Load and declare on class level. ImageButton save = new ImageButton(); save.ImageUrl = "save.gif" save.Click += new...
3
by: Benjamin Gavin | last post by:
Hi all, I recently stumbled upon a bug in the ASP.NET framework handling of ImageButton based postbacks. The issues derives from the fact that IE and Mozilla handle the case of a missing image...
13
by: tperri | last post by:
I have an HTML table with several fields like this: <A href="Savings.aspx?category=Food"><asp:imagebutton id="imgFood" ImageUrl="images\buttons\btn-food-i.gif"...
0
by: Oddball | last post by:
I have set up a page with uses two lots of image buttons, one for a collection and one for more images from that collection. I generate all the image buttons on page init (I know, but I...
2
by: Robert Smith jr. | last post by:
Hello, Please pardon my newbie question ... I am building an ASP.NET page that displays a recordset with a Delete statement enabled (this all works fine). I want to Insert the current row...
4
by: suzanne.boyle | last post by:
Hi, I'm adding an ImageButton as a child to a custom web control and attaching an event handler to it. When the page posts back the event is not being fired however. I initially assumed I had...
8
by: brock wade | last post by:
I have a Datagrid that is working fine displying my records, but I'm trying to program buttons on each record line to launch another web page that shows all the details for the product: ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.