Image in layout.master

A place for discussion about skinning and design. Before posting questions here you should review the documentation about creating skins.

This thread is closed to new posts. You must sign in to post in the forums.
1/16/2009 1:02:23 PM
Gravatar
Total Posts 5

Image in layout.master

I am trying to add an image within a layout.master, but I'm having trouble with the path.

My images are located in the root of the theme, CSS works fine, but just having <img src="myimage.gif" /> doesn't work.

Thanks,
-Damien

1/16/2009 2:05:06 PM
Gravatar
Total Posts 18439

Re: Image in layout.master

Hi Damien,

You can do it using syntax like this:

src='<%= Page.ResolveUrl("~/Data/Sites/1/skins/mojosite-brightside/paypal-donate.gif")%>'

so you have to put the complete relative path and use single quotes for src='' because it has double quotes inside the function call.

Hope it helps,

Joe

10/5/2009 9:55:25 PM
Gravatar
Total Posts 1
Mark Milbourne www.milbourne.com

Re: Image in layout.master

Hey Guys,

I've also stumbled across this problem.  Is there a way to query the directory of the current skin?  Then do this;

src='<%= Page.CurrentSkinDirectory() + ("/paypal-donate.gif")%>'

I search for API docs on the website but I couldn't find them. 

Cheers

Mark

PS: I recently discovered mojoPortal and I love it.  Solves so many of my problems.  :-)

 

 

10/6/2009 6:01:48 AM
Gravatar
Total Posts 18439

Re: Image in layout.master

Hi Mark,

Yes there is an easy way its just a gap in documentation.

You can add an image from the skin folder to layout.master like this:

<portal:SkinFolderImage ID="imgs1" runat="server" ImageFileName="sun5.gif" CssClass="sunheader" />

so you only have to put the image file name and it will resolve the rest of the url correctly.

Hope it helps,

Joe

10/6/2009 8:55:00 AM
Gravatar
Total Posts 2253

Re: Image in layout.master

I have used this in the past and it works great:

 <img class="bg" src="dsc06798-modified.jpg" alt="My Little Place on The Web" runat="server" />

The key is the runat="server", .NET will re-base the url path to the image to the directory which contains the layout.master file. This can be used in any .NET app, not just mojoPortal.

HTH,
Joe D.

 

You must sign in to post in the forums. This thread is closed to new posts.