Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    May 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Set an image source dynamically from a variable or QueryString

    Hi,

    I have a simple request. How do I set the source of an image in an ASP page using a variable? Example:

    <script runat="server">
    protected void Page_Load(Object Source, EventArgs E)
    {
    String Image = "http://www.codingforums.com/img/logo.gif";
    }
    </script>

    <asp:Image ID="Image1" runat="server" ImageUrl = (Image Variable) />

    Any reply would be greatly appreciated!

    QF

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,047
    Thanks
    0
    Thanked 251 Times in 247 Posts
    This should be in ASP.NET forums. I'm not a .NET developer but I'll make an educated guess.

    Code:
    String Image = "http://www.codingforums.com/img/logo.gif";
    Image1.ImageUrl = Image;

  • #3
    New Coder
    Join Date
    May 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Glenn,

    I believe that's the correct approach. It just doesn't appear to work for me...

    In my ASP page I have this code:

    <asp:image runat ="server" ID = "Image1" />

    And in the Code Behind page, I have the code you listed.

    M

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,047
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Is there any error? You may want to ask the mods to move this thread to ASP.NET Forum to get more useful answers.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •