Using the code behind to show an image

  • Thread starter Thread starter bthumber
  • Start date Start date
B

bthumber

How do you made a reference to an image in the code behind? I'm trying to
show a high priority "!" image if an "h" was in the label. Please the code
below.

view plaincopy to clipboardprint?
private void ShowPriority()
{
StorePriority.Value = "n";
myLabel.Text = StorePriority.Value;
if(myLabel.Equal("n");
{
myLabel.Text = " ";
}
else
{
// How do reference the path to the image?
}
 
You have to use an asp:Image control, with ImageUrl property set to the
priority icon file. You can then show and hide the image according to the
priority.


private void ShowPriority()
{
StorePriority.Value = "n";
myLabel.Text = StorePriority.Value;
yourImage.ImageUrl = "....";

if(myLabel.Equal("n");
{
myLabel.Text = " ";
yourImage.Visible = false;
}
else
{
yourImage.Visible = true;
}

Sarath Babu S
http://www.consultsarath.com
 
Back
Top