views:

1054

answers:

2

I'm having a bit of trouble with an old delphi.net application.

I need to show some thumbnail images on a specific location on the page, and when the user clicks the image show the image.

The images are rather small so I havn't bothered with thumbnail generation.

The problem is that I can't get the onclick event working.

Here is my code: (This is in the page_load event)

filer := Directory.GetFiles(dirstr,soegestr);
for f in filer do
begin
   img := ImageButton.Create;
   img.ImageUrl := f;
   img.Width := 30;
   img.Height := 50;
   img.Style.Add('margin-right','10px');
   include(img.Click, FragtbrevsBilledeClick);
   PanelBilleder.Controls.Add(img);
end;

include does nothing. The onclick event just triggers a postback.

FragtbrevsClick is defined as follows:

procedure TWebForm1.FragtbrevsBilledeClick(Sender: TObject;
   e: ImageClickEventArgs);
begin
  Response.Redirect((sender as ImageButton).ImageUrl);
end;

Setting a breakpoint in fragtbrevs clicks never gets hit.

I'm not a reguler web developer so alternative ways to solve the problem is also welcome! :-)

A: 

Is there a function FragtbrevsBilledeClick?

What does this function do?

Chris Ballance
Added fragtbrevsbillede click to original post. It's not at function. Could that be the problem.
olve
+1  A: 

All you should need to do is set the ImageButton's PostBackURL property (as well as any other properties you like). There is no need for a Click event handler. When the button is clicked, it will automatically redirect to the PostBackURL location. This should suffice, given that you are not doing anything else in the FragtbrevsBilledeClick event handler.

Cary Jensen