PDA

View Full Version : Connecting to master from child


Montague
07-09-2009, 05:06 AM
My master page imports two style sheets.
<%@ Master Language="VB" CodeFile="Site.master.vb" Inherits="Site" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Master Title</title>
<style type="text/css" media="all">
@import "skidoo_too_base.css";
@import "skidoo_too_theme.css";
</style>
</head>

Because of this, my child pages will only work if they are in the root directory. As soon as I try to implement a child from a subdirectory, it breaks.

I have implemented a fix, by writing a module based on http://odetocode.com/Blogs/scott/archive/2005/12/09/2604.aspx but it does not work.
I have tried to research on ResolveClientURL, but the closest I get to this problem is "with @import your child will break". Nothing like a fix. And you cannot use ResolveClientURL in the @Page line.

using <%@ Page Title="" Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="FTPSquads_Default" %>
<%@ MasterType VirtualPath ="~/Site.master" %> does not work.

Is there anyone that can teach me how to write a class definition .. or something with code-behind, that would possible resolve my problem?

Montague
07-09-2009, 05:35 AM
I have solved my problem, by combining my sheets into one.

scottk
07-16-2009, 01:18 AM
You have another option using placeholders in the Master Page that you could use.

Master.cs:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<asp:ContentPlaceHolder EnableViewState="False" ID="localCssPlaceholder" runat="server"></asp:ContentPlaceHolder>
</head>


Child.cs:

<asp:Content ID="Content1" ContentPlaceHolderID="localCssPlaceholder" runat="server">
</asp:Content>


Then you could override where the stylesheet is being linked on child pages.