Using the code behind to show an image

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?
}
 
S

Sarath Babu S

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top