473,411 Members | 2,083 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,411 software developers and data experts.

ImageButton click even refuses to fire


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
Page_Load... this can't be right can it? Help!

If you need any more information please ask - the code follows.

--> Oddball

++++ START CODE ++++

// Create a new ImageButton for the main collection
ImageButton newImageButton = new System.Web.UI.WebControls.ImageButton();

// Set the URL to the relevent thumbnail image
newImageButton.ImageUrl = "/thumbnail.aspx?id=" + fiRow[ADM.IMAGEID_FIELD] +
"&mode=h&scale=88";

// And give it the right CSS class
newImageButton.CssClass = UNSELECTED_CLASS;

// Use CommandName and CommandArgument to store data
newImageButton.CommandName = "" + seats;
newImageButton.CommandArgument = fRow[ADM.FURNITUREID_FIELD].ToString();

// Associate the event (this one works!!!)
newImageButton.Click += new ImageClickEventHandler(CollectionItemButton_Click) ;

// Now get the images for that piece
DataTable fTab = Catalogue.Tables[ADM.FURNITURE_TABLE];
// Get an array of FurnitureImage rows
fiRowArray =
fRow.GetChildRows(ADM.FURNITURE_FURNITUREIMAGE_REL ATION);

// Create the array that will hold the MoreImages
ImageButton[] NewMoreImagesArray = new ImageButton[fiRowArray.Length];

// Counter for counting stuff
int count = 0;

// Right - work through each furniture image row and create a button for it
foreach (DataRow fimiRow in fiRowArray)
{
// One blank button - ready to go
ImageButton iB = new System.Web.UI.WebControls.ImageButton();

// Set to the thumbnail
iB.ImageUrl = "/thumbnail.aspx?id=" + fimiRow[ADM.IMAGEID_FIELD] +
"&mode=w&scale=106";

// Set the class
iB.CssClass = UNSELECTED_CLASS;;

// Data
iB.CommandName = "" + seats;
iB.CommandArgument = fRow[ADM.FURNITUREID_FIELD].ToString();

// Associate the MoreImages event ( THIS DOES NOT WORK!!! )
iB.Click += new ImageClickEventHandler(MoreImagesButton_Click);

// And add the button to the array....
NewMoreImagesArray[count] = iB;

// Count something
count++;
}

// Add all this gubbins to the correct arrays
CollectionItemsArray[seats] = newImageButton;
MoreImagesArray[seats] = NewMoreImagesArray;

++++ END CODE ++++
------------------------------------

Another unchecked rambeling brought to you by:

Oddball
joshua@bf#N0SP4M#wd.co.uk
Nov 19 '05 #1
0 1478

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

Similar topics

4
by: angus | last post by:
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"...
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...
0
by: hn | last post by:
I have an imagebutton as a datalist item. When I click on the image button, the event is not fired. It works fine with Linkbutton. Please help. The code snippet is as followed: <asp:datalist...
1
by: MattB | last post by:
I have a button column in a datagrid that is the delete button. Right now it is just a text link. When I go into the Property Builder My button choices are only LinkButton or PushButton. I'd like...
3
by: TCORDON | last post by:
Why does the click event of an image button that submitts a form does not get fired when ENTER is pressend on a textbox of that form? How can I make this happen? Thanks
3
by: jens.buchta | last post by:
Hi! I'm using a DataGrid with a template column to display an Image inside of it. I'm hooking into its OnPrerender-Event to set the ImageURL-Property dynamically. Everything works just fine...
0
by: Tom Edelbrok | last post by:
I'm using VS 2005 to develop an intranet asp.net web application and I get a weird situation. If I start out with any ASPX page that contains an ImageButton control followed by a TextBox control,...
0
by: Yourself | last post by:
Hi, I'm using an ImageButton in my web form for a text sizer application: <asp:ImageButton id="btnSmall" runat="server" width="18" height="18" /> and then in the click event, I do some stuff. ...
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...
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: 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
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,...
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
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.