locked
How to use Master Page in VirtualPathProvider RRS feed

  • Question

  • Hi,

    I am storing all pages in database and code behinds in file system.  I am also using master page in virtual pages.  Pages are being compiled and rendered properly in aspx content doesn't have MasterPageFile attribute in <%@ page directive.  But when Page directive has MasterPageFile attribute than it is throwing exception below:
    Content controls have to be top-level controls in a content page or a nested master page that references a master page. body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } pre {font-family:"Lucida Console";font-size: .9em} .marker {font-weight: bold; color: black;text-decoration: none;} .version {color: gray;} .error {margin-bottom: 10px;} .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }

    Server Error in '/VirtualPathTest' Application.

    Content controls have to be top-level controls in a content page or a nested master page that references a master page.


    Here is the Content page html

    <%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/vrdir/MasterPage.Master" CodeFile="~\CodeBehind\Default3.aspx.cs" Inherits="Default3" %>
    <asp:Content ID="mainPage" ContentPlaceHolderID="ContentPlaceHolder1">
    <div>This is content page</div>
    </asp:Content>

    and here is the Master Page Html

    <%@ Master Language="C#" AutoEventWireup="true" CodeFile="~\CodeBehind\MasterPage.master.cs" Inherits="MasterPage" %>

    <!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 runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>This is master Page</div>
        <div>
            <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
           
            </asp:ContentPlaceHolder>
        </div>
        </form>
    </body>
    </html>

    I spent entire day to get this thing work but failed,  I am not able to debug it.

    Help is highly appreciated.
    Tuesday, February 17, 2009 4:23 AM