Welcome to Sign in | Join | Help
in
Home Forums Photos Downloads

Masterpage-dependent ASP.NET pages not picking up logo

Last post 03-31-2008, 9:41 PM by andersonimes. 2 replies.
Sort Posts: Previous Next
  •  09-27-2007, 3:21 PM 1137

    Masterpage-dependent ASP.NET pages not picking up logo

    I'm using ASP.NET and the masterpage architecture on my asp.net portal and when I add a logo to the master page, despite every other page using that same one masterpage, only the homepage will pick up the logo in the masterpage.

     

    So if I add a logo on my masterpage, only the homepage (default.aspx) which is based off site.master will show the logo. Any other page won't. This is despite updating the files on the server (logo, masterpage, etc).

     

    Why is this? I know this isn't really a pre-sales question but this seems to be the best place to ask. Is this a hosting issue?

  •  09-27-2007, 3:43 PM 1138 in reply to 1137

    Re: Masterpage-dependent ASP.NET pages not picking up logo

    A few thoughts:

    1.  Are the pages that won't show the image in a different folder than default.aspx?  If so, it's a mapping problem.

    2.  Do the pages that don't show the logo have the MasterPageFile="site.master" in the Page declaration at the very top?  If not, add it so it uses the site.master.

    Also, if your masterpage is in the root of the application but your aspx page isn't (similar to #1 above), make sure you reference the virtual path to the masterpage like so:

    <%@ Page Language="VB" MasterPageFile="~/site.master" AutoEventWireup="false" CodeFile="mypage.aspx.vb" Inherits="mypage" title="Untitled Page" %>


    William Eaton, MCSE
    iTech Computer Solutions, LLC
    www.itechcs.com
    Filed under:
  •  03-31-2008, 9:41 PM 1456 in reply to 1137

    Re: Masterpage-dependent ASP.NET pages not picking up logo

    The easiest thing to do here is to make sure that you are using a WebConrol for the image (like System.Web.UI.WebControls.Image") and set the ImageURL property to one that is rooted to the application.

     An example would be if the image is in /images/myimage.gif, you would specify the url as "~/images/myimage.gif".  It will automatically translate the tilde (~) into the root of the application.  This way the path will always be correct no matter what the folder hierarchy of the page is.

    If you cannot use a WebControl, there is a method defined on Control (and subsequently any Usercontrols or Pages) called "ResolveURL".  You wold pass this the ~ rooted URL and you would get back the correct url.  An example of using this in code would be:

    <img src='<%= this.ResolveURL("~/images/myimage.gif") %' />

    Hope this helps.

View as RSS news feed in XML
Powered by Community Server, by Telligent Systems