div Background not showing on pages in sub folder.

D

Dave

I have a site that I'm trying to use Nested Master pages on certain
pages on my site. Both Master Pages reside in the root of my site and
the graphics are in an images folder. When setting up pages in a
restricted folder the images on the master doesn't display when
rendered. Below is a portion of my master page. Can someone tell me
why the TriR_Header.png doesn't display as soon as I navigate to the
pages in the restricted folder? If setting the DIV background-image
isn't the the right approach, I'm open to suggestions. I'd like to
only use 1 master page throughout the site.

Thanks for your time.



<div id="Header" align="Right"
style="height: 60px; width: 1024px; background-image: url
('images/TriR_Header.png');">
<table style="height: 100%">
<tr>
<td valign="bottom">
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="~/Default.aspx" Style="color: #FFFFFF;
font-weight: 700; font-family: Tahoma;
font-size: 10pt">Home</asp:HyperLink>
</td>
<td valign="bottom">
<asp:HyperLink ID="ContactUsHyperLink0"
runat="server" NavigateUrl="~/RUA.aspx"

Style="color: #FFFFFF; font-weight: 700;
font-family: Tahoma; font-size: 10pt">Request Account</asp:HyperLink>
</td>
<td valign="bottom">
<asp:HyperLink ID="ContactUsHyperLink"
runat="server" NavigateUrl="~/ContactUs.aspx"
Style="color: #FFFFFF; font-weight: 700;
font-family: Tahoma; font-size: 10pt">Contact Us</asp:HyperLink>
</td>
<td valign="bottom">
<asp:LoginStatus ID="LoginStatus1"
runat="server"

style="color: #FFFFFF; font-size: 10pt;
font-family: Tahoma; font-weight: 700"
onloggedout="LoginStatus1_LoggedOut" />
</td>
<td valign="bottom">
&nbsp;
</td>
</tr>
</table>
</div>
 
Joined
May 16, 2006
Messages
27
Reaction score
0
In your master page, create a protected function to get the image path,

In Vb,

Protected Function GetImagePath(ByVal imageFile As String) As String
If (System.IO.Directory.Exists(Server.MapPath("images"))) Then
Return "images/" + imageFile
End If
If (System.IO.Directory.Exists(Server.MapPath("../images"))) Then
Return "../images/" + imageFile
End If
If (System.IO.Directory.Exists(Server.MapPath("../../images"))) Then
Return "../../images/" + imageFile
End If
If (System.IO.Directory.Exists(Server.MapPath("../../../images"))) Then
Return "../../../images/" + imageFile
End If
End Function

In C#,

protected string GetImagePath(string imageFile)
{
if ((System.IO.Directory.Exists(Server.MapPath("images")))) {
return "images/" + imageFile;
}
if ((System.IO.Directory.Exists(Server.MapPath("../images")))) {
return "../images/" + imageFile;
}
if ((System.IO.Directory.Exists(Server.MapPath("../../images")))) {
return "../../images/" + imageFile;
}
if ((System.IO.Directory.Exists(Server.MapPath("../../../images")))) {
return "../../../images/" + imageFile;
}
}


use this in your aspx page,

<div id="Header" align="Right" style="height: 60px; width: 1024px; background-image: url('<%=GetImagePath("TriR_Header.png")%>');">
 
D

Dave

Many Thanks to a co-worker!

<style type="text/css">
div.one
{
z-index: 1;
margin-left: 11px;
margin-top: 11px;
}
div.two
{
z-index: 2;
width:1024px;
left: 11px;
margin-top: -23px;
background-color: Transparent;
}
div.three
{
width: 1024px;
text-align: left;
background-color: #FFFFFF;
text-align: left;
}
div.four
{
position: relative;
width: 1024px;
height: 30px;
}
</style>
<body bgcolor="#cccccc" style="text-align: center;">
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div align="center">
<div id="Header" class="one">
<asp:Image ID="Image1" runat="server" ImageUrl="images/
TriR_Header.png" />
<div />
<div align="center">
<div id="menu" class="two" align="right">
<table style="height: 100%">
<tr>
<td valign="bottom">
<asp:HyperLink ID="HyperLink1"
runat="server" NavigateUrl="~/Default.aspx" Style="color: #FFFFFF;
font-weight: 700; font-family:
Tahoma; font-size: 10pt">Home</asp:HyperLink>
</td>
<td valign="bottom">
<asp:HyperLink
ID="ContactUsHyperLink0" runat="server" NavigateUrl="~/RUA.aspx"
Style="color: #FFFFFF;
font-weight: 700; font-family:
Tahoma; font-size: 10pt" Enabled="False" ToolTip="This option is not
available at this time.">Request Account</asp:HyperLink>
</td>
<td valign="bottom">
<asp:HyperLink ID="ContactUsHyperLink"
runat="server" NavigateUrl="~/ContactUs.aspx"
Style="color: #FFFFFF; font-
weight: 700; font-family: Tahoma; font-size: 10pt">Contact Us</
asp:HyperLink>
</td>
<td valign="bottom">
<asp:LoginStatus ID="LoginStatus1"
runat="server" Style="color: #FFFFFF; font-size: 10pt;
font-family: Tahoma; font-weight:
700" OnLoggedOut="LoginStatus1_LoggedOut" />
</td>
<td valign="bottom">
&nbsp;
</td>
</tr>
</table>
</div>
</div>
</div>
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top