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 2 of 2
  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
    New Coder
    Join Date
    Mar 2006
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can set the ImageURL property in the Page_Load.
    Code:
    <script runat="server">
    
    protected void Page_Load(Object Source, EventArgs E) 
    {
    Image1.ImageURL = "http://www.codingforums.com/img/logo.gif";
    }
    
    </script>
    
    <asp:Image ID="Image1" runat="server" />
    Hope this helps.


  •  

    Posting Permissions

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