Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 6 of 6

Thread: V9 Master Pages / Images

  1. #1
    ssgumby is offline Senior Member
    Join Date
    Feb 2009
    Posts
    683

    Default V9 Master Pages / Images

    If I had an image like this

    Code:
    <img src="skins/skin_2/images/logo.gif" width="333" height="95" alt="My Image" title="My Image" />
    What would the equivalent be in master pages?

  2. #2
    ssgumby is offline Senior Member
    Join Date
    Feb 2009
    Posts
    683

    Default

    I guess the simple answer is

    Code:
    <img src="App_Themes/Skin_2/images/logo.gif" width="333" height="95" alt="My Image" title="My Image" />
    Is there some other way other than hard coding the path? Like some way that it will know which skin id im using and look it up?

  3. #3
    ASPAlfred is offline Senior Member
    Join Date
    Nov 2007
    Posts
    2,244

    Default

    If you have images inside the .aspx form, make sure you are using the relative path and it should always have an runat="server" property so it is parsed correctly. In your case, you should do it like this:

    Code:
    <img runat="server" src="App_Themes/Skin_2/images/logo.gif" width="333" height="95" alt="My Image" title="My Image" />
    or better yet, use the <asp:Image> element:
    Code:
    <asp:Image runat="server" ImageUrl="~/App_Themes/Skin_2/images/logo.gif" />

  4. #4
    mbertulli is offline Senior Member
    Join Date
    Aug 2008
    Posts
    243

    Default

    Or, even better, use this

    No need to specify the full App_Themes/Skin folder.

    <asp:Image ID="logo" runat="server" ImageUrl="<%$ Tokens:SKINIMAGE, logo.gif %>" />
    Matthew Bertulli
    Demac Media
    mbertulli@demacmedia.com
    Custom Web Design & E-Commerce Development
    AspDotNetStoreFront Platinum DevNet Partner
    ----

    Custom Skinning & Design
    Web Services Integration
    Custom Reporting
    Salesforce.com eCommerce AspDotNetStoreFront Integration

  5. #5
    ssgumby is offline Senior Member
    Join Date
    Feb 2009
    Posts
    683

    Default

    Thanks Matt, that was exactly what I was looking for!

  6. #6
    DanV's Avatar
    DanV is offline Ursus arctos horribilis
    Join Date
    Apr 2006
    Posts
    1,568

    Cool

    Which brings up a good "Best Practice". If you are accessing files in your skin OUTSIDE of the App_Themes directory, then always do path from application root. For example,

    Code:
    <img src="./images/myimage.gif" />
    will work ok, however if you ever turn on some of the other routing engine rules this will start breaking all over the place. The alternative is:

    Code:
    <img runat="server" id="imgMyImage" src="~/images/myimage.gif" />
    This causes .NET to parse the image path from whereever the root of your application is so no matter how many directories you are deep, the right path is always set. If your are in mystore.com/stuff/someotherstuff/page.aspx, that code would return "../../images/myimage.gif"