tags:

views:

488

answers:

3

Hi,

I am trying to convert my web application into a fully dynamic system. One thing I am trying to do is to load a different logo (set in the masterpage template) depending on the host.

But, even though the code is hit (in page_init), there is no image displayed on any page inheriting the masterpage - no image, no red x's, nothing.

My code looks like this (from masterpage, the path to the image is correct and pasted from Windows Explorer's property window path):

Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
    If Request.Url.Host.Contains("localhost") Then
        Image1.ImageUrl = "C:\Users\firstname.lastname\Documents\Visual Studio 2008\WebSites\ecardsystem\images\ECard Platform.jpg."


    End If

End Sub

I know that I can add the image on the fly using literal controls through codebehind, but this will mean I need to design the html too, by hand, when the design is all done and perfect. Thus this approach will create a bit more work.

Thanks

+1  A: 

Have you tried using a virtual path to the image relative to you website? Internet Explorer will generally not show images from a users local file system with the default security settings. Try putting the image in an images directory in your project and setting the URL to it's relative path:

Image1.ImageUrl = "~/images/Card Platform.jpg."
duckworth
A: 

Hi,

Thanks, that works!

dotnetdev
A: 

Image1.ImageUrl = "~/images/Card Platform.jpg." works on local server not on production server :( What can be the problem ?