ASP.NET Image tags with local src values

Discussion in 'ASP .Net' started by Robbe Morris - [MVP] C#, Sep 18, 2007.

  1. I've never had to do this before...

    I have a web app that needs to look for image files outside the
    web site folders if it is run on localhost but look for the image files
    in sub folders of the web site if run anywhere else. And yes, there
    is a logical reason for this...

    For some reason, I can't get the local image file to be rendered
    in the page when going to localhost:

    <asp:ImageButton ID="ImageButton1" runat="server"
    ImageUrl="file:///D:\inetpub\Submit_en-us.gif" OnClick="imgSubmit_Click" />

    I know that this is the proper path as I pasted it into a test.htm file and
    the image
    file showed up properly.

    This seems rather odd. Anyone with insight?
    Robbe Morris - [MVP] C#, Sep 18, 2007
    1. Advertisements

  2. You cannot do it this way. But, you can set it up to get the image locally
    and serve it through an image handler. Something like:

    <img src="imageHanlder.aspx?id=1234" />

    This is a fairly common activity.

    If you must stick with your method, you will either have to customize your
    own image button control or move to an HTML image control. This will avoid
    the url writing of the string.
    Cowboy \(Gregory A. Beamer\), Sep 18, 2007
    1. Advertisements

  3. Robbe Morris - [MVP] C#, Sep 18, 2007
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.