views:

22

answers:

1

Hello.

I have created a simple method to check if an image has been approved and finally returns it as an control. But how do i call and show it on the page? I've tried something like this in the aspx-file:

<% SendImage("DKBygMiniLogo.gif", "True"); %>

Here is the simple method:

protected Image SendImage(object Image, object Approved)
{
  bool approved = Convert.ToBoolean(Approved);
  Image img = new Image();
  if (approved)
  {
      img.ImageUrl = "~/images/Ads/" + Image.ToString();
      img.Visible = true;
  }
  else
  {
      img.ImageUrl = "~/images/Ads/" + Image.ToString();
      img.Visible = false;
  }
   return img;
}

How do I actually show the image?

A: 
Jamie Dixon
You cannot add a child control to a literal...
Dan
Thanks Dan, I've updated my answer. :-)
Jamie Dixon
Thanks. So adding it to a asp:Panel would be a possibility?
Andreas Strandfelt