Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
|
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 1st, 2011, 06:51 PM
Authorized User
 
Join Date: Jul 2009
Posts: 61
Thanks: 15
Thanked 1 Time in 1 Post
Default Problem with Nested master pages

Hi
I am developinga site whichI want to contacin 2 'sub sites' - one for business clients and one for Home clients.
I therefore want to base each 'sub site' on a slightly different master page.
I have a base master calleed master1.master:
Code:
  
<%@ Master Language="VB" CodeFile="Master1.master.vb" Inherits="Master1" %>

<!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">
  <meta name="google-site-verification" content="M8qVTfgjXH6dJaCEjTMmkerA4eFhIduDKXOMD3pRw5E" />
    <title></title>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
    <style type="text/css">
        </style>
<meta http-equiv="X-UA-Compatible" content="IE-7" />
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-21134926-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
</head>
<body id="body">
  <form id="form1" runat="server">
    <div id="pagecontainer">
       <div id="banner">
         <div id = "bannerimages">
             <div id="leftbanner">
             
             </div>
             <!--- <div id="centrebanner">
             </div>--->
             <div id="Rightbanner">
             </div>
        </div>
      </div>
      <div id="menu">
       <asp:ContentPlaceHolder id="menubar" runat="server"> 
       </asp:ContentPlaceHolder> 
      </div>
        
      <div id="leftsidebar" >

          <img alt="Menu Button for Nusiness Area" src="../Images/BusinessIn_Menu.jpg" />
          <img alt="White space" src="../Images/WhiteSpace.jpg" height="20px"/>
          <img alt="Menu Button for Home and Soha Area" src="../Images/HomeIn_Menu.jpg" />
        <asp:ContentPlaceHolder id="LeftColumn" runat="server">    
        </asp:ContentPlaceHolder>       
      </div>
        
      <div id="maincontent" >
        <asp:ContentPlaceHolder id="MainColumn" runat="server"> 
        </asp:ContentPlaceHolder>
      </div>
      <div id="rightsidebar">
      <asp:ContentPlaceHolder id="RightColumn" runat="server"> 
        </asp:ContentPlaceHolder>
      </div>
    </div>         
      <div id="Bottombanner"> 
      </div>
        
      <div id="footer">
        <p>Website design and maintenance by <a target="_blank" href="http://www.beaufortnetworks.com">Beaufort Networks Ltd</a></p>
      </div>
  </form>
</body>
</html>
I then created a home.master using master1.master as its master:

Code:
<%@ Master Language="VB" MasterPageFile="~/MasterPages/Master1.master" AutoEventWireup="false" CodeFile="Home.master.vb" Inherits="MasterPages_Home" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="menubar" Runat="Server">
  <asp:Menu ID="Menu1" runat="server" Orientation="Horizontal" align="center" 
                StaticEnableDefaultPopOutImage="True" MaximumDynamicDisplayLevels="3" 
           Width="362px">
            <StaticSelectedStyle CssClass="StaticSelectedStyle" />
            <StaticMenuItemStyle CssClass="StaticMenuItemStyle" />
            <StaticHoverStyle cssclass="StaticHoverStyle"/>
            <DynamicMenuItemStyle CssClass="DynamicMenuItemStyle" />
            <DynamicHoverStyle cssclass="DynamicHoverStyle"/>
            <Items>
              <asp:MenuItem NavigateUrl="~/AntiVirus-SOHO.aspx" 
                Text="AntiVirus Solutions" Value="AntiVirus Solutions"></asp:MenuItem>
              <asp:MenuItem NavigateUrl="~/Home-Backup.aspx" 
                Text="Backup " Value="Backup">
              </asp:MenuItem>
            </Items>
         </asp:Menu>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="LeftColumn" Runat="Server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="MainColumn" Runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="RightColumn" Runat="Server">
</asp:Content>
I then created a web page using home.master as the master page:
Code:
<%@ Page Title="Antivirus software for home PCs and networks from Kaspersky" Language="VB" MasterPageFile="~/MasterPages/home.master" AutoEventWireup="false" CodeFile="AntiVirus-SOHO.aspx.vb" Inherits="Anti_Virus_SOHO" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="LeftColumn" Runat="Server">
  <img src="Images/WhiteSpace.jpg" />

 <asp:Image ID="Image2" runat="server" CssClass="leftsidebar"
    ImageUrl="Images/Kaspersky/kis2010_eng_medium.jpg" Height="108px" Width="90px" />
   
    <h6>All Kaspersky products are available for free tial</h6>
     <p>
     Use the <a style="color: #005343; text-decoration: underline;" 
         99"href="Contact.aspx">Contact Form </a>to request a link to a free download and 30 
       day trial
     </p>
 </asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainColumn" Runat="Server">
<div id="maincontent">
   
  <h1>
    Keep your PCs and home network safe...</h1>
  
    <p>To keep your PC and home network secure from viruses, trojans and malicious 
      attack it is vital to install and maintain effective anti malware software.</p>
  <p>We recommend the Kaspersky product range which offers solutions to meet the 
    simplest or most demanding requirements.</p>
    
    <h4>Internet Security 2011</h4>
  
  <p>... combines antivirus protection with a personal firewall and an anti-spam 
    filter. Kaspersky Internet Security keeps your PC or Netbook free from malicious 
    code, adware, spyware, hacker attacks, dialers, spam and network fraud. </p>
  <h4>Kaspersky Pure</h4>
  <p>... builds on Internet Security to give you the ultimate in Home Security. 
    Password Manager stores and protects all your passwords and personal data 
    providing you with safe and secure access to your preferred websites and web 
    forms.</p>
  <h4>KryptoStorage</h4>
  <p>... protects your personal data against theft and unauthorized access using cutting-edge encryption technology, and allows deleted files to be permanently erased from your computer.

Encrypted data is stored in a password-protected digital container that only you can access. </p>
 </div> 
</asp:Content>

BUT... on the web page all the contentplace holders are flagged as in error
eg 'Could not fine "head" in the current master page or pages' where head is replaced by each placeholder
If I change the MasterPageFile= to point at master1.master the errors go away - but of course I dont have the differences in the page (at the moment just the menu)

I have tried the suggestions in http://forums.asp.net/t/1218788.aspx/2/10 but although the errors go away, the images in the Master1 left column don't get displayed and some of the css seems to disappear :(
__________________
Geoff Baldwin
 
Old March 3rd, 2011, 10:15 AM
Authorized User
 
Join Date: Jul 2009
Posts: 61
Thanks: 15
Thanked 1 Time in 1 Post
Default

OK - I fixed the problem using info at http://forums.asp.net/t/1218788.aspx/2/10

Some weird issues with some image URLs being flagged as invalid in VSE but actually working in the browser remain. As it works I probably won't try and fix it!
__________________
Geoff Baldwin





Similar Threads
Thread Thread Starter Forum Replies Last Post
General question - Master Pages, Base pages, templates and OOP. flapjack BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 May 1st, 2010 09:33 AM
Problem accessing Request.Form with Master Pages kittu_asa ASP.NET 2.0 Basics 1 February 28th, 2008 09:38 AM
Problem accessing Request.Form with Master Pages niceFEPF ASP.NET 2.0 Basics 7 February 14th, 2008 04:25 PM
Problem in nested master pages. harsh.kintu ASP.NET 2.0 Professional 2 January 9th, 2007 10:04 AM
strange "errors" with nested master pages... thenoseknows ASP.NET 2.0 Professional 2 November 28th, 2006 05:28 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.