473,699 Members | 2,385 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question about ImageButton Event

Dear all,

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

<asp:ImageButto n id="imagebutton 1" runat="server"
AlternateText=" Sort Ascending"
ImageUrl="image s/pict.jpg"
OnCommand="Imag eButton_Command "
CommandName="So rt"
CommandArgument ="Ascending"/>

But i have problem if i add that button in the codebehind,
Protected WithEvents imagebutton1As System.Web.UI.W ebControls.Imag eButton

ibtnSetup = New ImageButton

ibtnSetup.Image Url() = "icon-setup.gif"

ibtnSetup.Cause sValidation = False

ibtnSetup.Comma ndArgument = drRack.Item("LO CATION_ID")

Protected Sub ibtnSetup_Click (ByVal sender As Object, ByVal e As
CommandEventArg s) Handles ibtnSetup.Comma nd

Console.Write(e .CommandArgumen t)

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 1866
you need to add this event handler..

this.ImageButto n1.Click += new
System.Web.UI.I mageClickEventH andler(this.ibt nSetup_Click);

Av.

"angus" <an***@angus.co m> wrote in message
news:eD******** ******@TK2MSFTN GP11.phx.gbl...
Dear all,

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

<asp:ImageButto n id="imagebutton 1" runat="server"
AlternateText=" Sort Ascending"
ImageUrl="image s/pict.jpg"
OnCommand="Imag eButton_Command "
CommandName="So rt"
CommandArgument ="Ascending"/>

But i have problem if i add that button in the codebehind,
Protected WithEvents imagebutton1As System.Web.UI.W ebControls.Imag eButton

ibtnSetup = New ImageButton

ibtnSetup.Image Url() = "icon-setup.gif"

ibtnSetup.Cause sValidation = False

ibtnSetup.Comma ndArgument = drRack.Item("LO CATION_ID")

Protected Sub ibtnSetup_Click (ByVal sender As Object, ByVal e As
CommandEventArg s) Handles ibtnSetup.Comma nd

Console.Write(e .CommandArgumen t)

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.ImageButto n1.Click += new
System.Web.UI.I mageClickEventH andler(this.ibt nSetup_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******** ******@TK2MSFTN GP12.phx.gbl... you need to add this event handler..

this.ImageButto n1.Click += new
System.Web.UI.I mageClickEventH andler(this.ibt nSetup_Click);

Av.

"angus" <an***@angus.co m> wrote in message
news:eD******** ******@TK2MSFTN GP11.phx.gbl...
Dear all,

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

<asp:ImageButto n id="imagebutton 1" runat="server"
AlternateText=" Sort Ascending"
ImageUrl="image s/pict.jpg"
OnCommand="Imag eButton_Command "
CommandName="So rt"
CommandArgument ="Ascending"/>

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

ibtnSetup.Image Url() = "icon-setup.gif"

ibtnSetup.Cause sValidation = False

ibtnSetup.Comma ndArgument = drRack.Item("LO CATION_ID")

Protected Sub ibtnSetup_Click (ByVal sender As Object, ByVal e As
CommandEventArg s) Handles ibtnSetup.Comma nd

Console.Write(e .CommandArgumen t)

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.Cl ick, AddressOf ibtnSetup_Click

Av.

"Harry" <ha******@mail. hongkong.com> wrote in message
news:eq******** ******@TK2MSFTN GP12.phx.gbl...
i am using VB.net
this.ImageButto n1.Click += new
System.Web.UI.I mageClickEventH andler(this.ibt nSetup_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******** ******@TK2MSFTN GP12.phx.gbl...
you need to add this event handler..

this.ImageButto n1.Click += new
System.Web.UI.I mageClickEventH andler(this.ibt nSetup_Click);

Av.

"angus" <an***@angus.co m> wrote in message
news:eD******** ******@TK2MSFTN GP11.phx.gbl...
> Dear all,
>
> I know that i can add a button with oncommand event "ImageButton_Co mmand" > by
> using the asp:ImageButton tag in the aspx code.
>
> <asp:ImageButto n id="imagebutton 1" runat="server"
> AlternateText=" Sort Ascending"
> ImageUrl="image s/pict.jpg"
> OnCommand="Imag eButton_Command "
> CommandName="So rt"
> CommandArgument ="Ascending"/>
>
> But i have problem if i add that button in the codebehind,
>
>
> Protected WithEvents imagebutton1As System.Web.UI.W ebControls.Imag eButton >
> ibtnSetup = New ImageButton
>
> ibtnSetup.Image Url() = "icon-setup.gif"
>
> ibtnSetup.Cause sValidation = False
>
> ibtnSetup.Comma ndArgument = drRack.Item("LO CATION_ID")
>
> Protected Sub ibtnSetup_Click (ByVal sender As Object, ByVal e As
> CommandEventArg s) Handles ibtnSetup.Comma nd
>
> Console.Write(e .CommandArgumen t)
>
> 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******** ********@tk2msf tngp13.phx.gbl. ..
AddHandler ImageButton1.Cl ick, AddressOf ibtnSetup_Click

Av.

"Harry" <ha******@mail. hongkong.com> wrote in message
news:eq******** ******@TK2MSFTN GP12.phx.gbl...
i am using VB.net
this.ImageButto n1.Click += new
System.Web.UI.I mageClickEventH andler(this.ibt nSetup_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******** ******@TK2MSFTN GP12.phx.gbl...
you need to add this event handler..

this.ImageButto n1.Click += new
System.Web.UI.I mageClickEventH andler(this.ibt nSetup_Click);

Av.

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

"ImageButton_Co mmand"
> by
> using the asp:ImageButton tag in the aspx code.
>
> <asp:ImageButto n id="imagebutton 1" runat="server"
> AlternateText=" Sort Ascending"
> ImageUrl="image s/pict.jpg"
> OnCommand="Imag eButton_Command "
> CommandName="So rt"
> CommandArgument ="Ascending"/>
>
> But i have problem if i add that button in the codebehind,
>
>
> Protected WithEvents imagebutton1As

System.Web.UI.W ebControls.Imag eButton
>
> ibtnSetup = New ImageButton
>
> ibtnSetup.Image Url() = "icon-setup.gif"
>
> ibtnSetup.Cause sValidation = False
>
> ibtnSetup.Comma ndArgument = drRack.Item("LO CATION_ID")
>
> Protected Sub ibtnSetup_Click (ByVal sender As Object, ByVal e As
> CommandEventArg s) Handles ibtnSetup.Comma nd
>
> Console.Write(e .CommandArgumen t)
>
> 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
3637
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 am trying to do. The ImageButton that is on the form handles its Command event just fine, but the ImageButton that is added to the cell does not handle the event. Am I doing something wrong, or is not possible to add server controls to a calendar...
5
6171
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 Click event to the ImageButton Column and it makes no difference, I still get a postback. This is driving me crazy...something seems to be causing an OnClick postback and it isn't my Click event I've included the code below....any help will be...
1
3343
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 ImageClickEventHandler(this.save_click); This ImageButton is added to a dynamic table which is also
3
2803
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 file differently. In both cases, the setup for the problem is: 1. Create a form with an ImageButton whose ImageURL is invalid, specify an AlternateText value 2. Submit the form through that ImageButton
13
7439
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" runat="server"></asp:imagebutton></A> When the user sees these buttons, they will currently be on the savings.aspx?category=whatever page, and when they click another button to look at other categories, all the links I have around these buttons direct to their various categories.
0
1506
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 implemented that as part of trying to solve this already existant problem). The CollectionItemButton_Click event will fire, but the MoreImagesButton_Click will not. I just don't get it. Someone, somewhere told me that I have to reassociate event on...
2
6546
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 *that is going to be deleted* into another table, before the original data is deleted. I am trying to use the RowDeleting method to call an Update or Insert
4
2089
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 missed some code or something however after playing about I've found that if I change the control to a Button (or a LinkButton) the event fires. Here is the code called in the overridden CreateChildControls method. ImageButton btn = new...
8
1254
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: <asp:datagrid id="dgProducts" runat="server"> <asp:ButtonColumn Text="Details" CommandName="Details" ButtonType="PushButton"></asp:ButtonColumn> </asp:datagrid>
0
8685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8613
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9172
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9032
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8880
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7745
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4374
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.