Event handler never called.

G

glenwilkin

The code below works, except the lButton_Click event handler is never called
when any of the ImageButtons are clicked. I've done this loads of times in
2003, what am I doing wrong in 2005?
ImageMaker.aspx is just a WebForm that BinaryWrites the applicable Image as a
byte[].

Code:
protected void Page_Load(object sender, EventArgs e)
{
this.getThumbnails();
}

private void getThumbnails()
{
System.Web.UI.WebControls.ImageButton lButton;
foreach (string lFile in Directory.GetFiles(@"C:\Graphics\Ethan"))
{
lButton = new System.Web.UI.WebControls.ImageButton();
lButton.ID = lFile;
lButton.ImageUrl = "ImageMaker.aspx?ImageAddress=" + lButton.ID;
lButton.Click +=new ImageClickEventHandler(this.lButton_Click);
this.pnlThumbnails.Controls.Add(lButton);
}
}

private void lButton_Click(object sender, ImageClickEventArgs e)
{
ImageButton lButton = sender as ImageButton;
this.imgMain.ImageUrl = "ImageMaker.aspx?ImageAddress=" + lButton.ID +
"&ImageType=full";
th
 

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

Top