1

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! :-)

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.