By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,189 Members | 2,167 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,189 IT Pros & Developers. It's quick & easy.

ImageButton click even refuses to fire

P: n/a

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
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.