How do I show and position an Image initialized in the codebehind on my page?
Posted
by Andreas Strandfelt
on Stack Overflow
See other posts from Stack Overflow
or by Andreas Strandfelt
Published on 2010-04-30T09:37:22Z
Indexed on
2010/04/30
9:47 UTC
Read the original article
Hit count: 223
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?
© Stack Overflow or respective owner