Using the code behind to show an image

Discussion in 'ASP .Net' started by bthumber, Jun 25, 2010.

  1. bthumber

    bthumber Guest

    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?
    }
     
    bthumber, Jun 25, 2010
    #1
    1. Advertising

  2. 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



    "bthumber" <> wrote in message
    news:...
    > 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?
    > }
     
    Sarath Babu S, Jul 8, 2010
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben Miller [msft]

    Re: Code Behind vs. no code behind: error

    Ben Miller [msft], Jun 27, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    643
    Alphonse Giambrone
    Jun 28, 2003
  2. jef
    Replies:
    1
    Views:
    4,441
    Steve C. Orr [MVP, MCSD]
    Mar 21, 2005
  3. Daniel Manes

    Code-Behind Pain in the Behind!

    Daniel Manes, Jun 10, 2005, in forum: ASP .Net
    Replies:
    11
    Views:
    709
  4. Disco Octopus

    to show image or to show flash

    Disco Octopus, May 13, 2004, in forum: HTML
    Replies:
    7
    Views:
    2,454
    Toby A Inkster
    May 14, 2004
  5. John

    Non-code behind to code behind

    John, Feb 19, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    527
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Feb 19, 2007
Loading...

Share This Page