ImageButton click even refuses to fire

O

Oddball

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_RELATION);

// 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top