Jens,
With thwe ImageButton you can setup both the Click and Command events. Do
you setup one of them?
Eliyahu
<> wrote in message
news: ups.com...
> Hi!
>
> I'm using a DataGrid with a template column to display an Image inside
> of it. I'm hooking into its OnPrerender-Event to set the
> ImageURL-Property dynamically.
> Everything works just fine here, until I thought "It would be cool, if
> the user could click on that image..". So I replaced the Image-Control
> with an ImageButton.
>
> My Problem is, that the ImageButton doesn't fire any events. Any other
> control works just fine but I'm having no luck getting the ImageButton
> to work.
>
> I'm happy about any ideas..
>
> Regards
> Jens
>
>
> ------------------------------------------------
> Code-Snippet
>
> -------------------
> aspx-Page
>
> <asp:TemplateColumn HeaderText="Images">
> <ItemTemplate>
> <asp:Image id="imgPic" runat="server"
> OnPreRender="imgPic_PreRender"></asp:Image>
> <asp:ImageButton id="ibtnPic" runat="server"
> OnPreRender="ibtnPic_PreRender"></asp:ImageButton>
> </ItemTemplate>
> </asp:TemplateColumn>
>
> -------------------
> CodeBehind
>
> protected void imgPic_PreRender(object sender, System.EventArgs e)
> {
> //this works as expected
> Image img = sender as Image;
> if (img == null)
> {
> return;
> }
> img.ImageURL = "dynamically-assigned.jpg";
> }
>
> protected void ibtnPic_PreRender(object sender, System.EventArgs e)
> {
> //this does not work
> //
> //if I rename this Method for testing purposes, the Page can't
> //be loaded, as it doesn't find this Method
> //
> //if I set a Break-Point to first method, the program does not
> //stop
> ImageButton ibtn = sender as ImageButton;
> if (ibtn == null)
> {
> return;
> }
> ibtn.ImageURL = "dynamically-assigned.jpg";
> }
>
|