ASP.NET Image tags with local src values

  • Thread starter Robbe Morris - [MVP] C#
  • Start date
R

Robbe Morris - [MVP] C#

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?
 
C

Cowboy \(Gregory A. Beamer\)

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.
 

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,756
Messages
2,569,535
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top