kwilliams
01-08-2007, 12:06 PM
I'm creating a site that's going to use the ASP.NET Master Page Control to transform XML/XSLT data into the content section of an ASP.NET form. I've already created the basic setup for the site (code below), and some of the content, but I have a few questions/concerns about this method:
What I don't like about the Master Page Control so far is the size of the pages. I haven't even put any content on the main section of the page, and it's already 31043 bytes in size. What are some steps that I can take to optimize this site (i.e. caching)? Also, how should I go about creating and processing a form within a transformed page using the Master Page control? Should I use XForms (like http://www.w3schools.com/xforms/default.asp) or dynamic ASP.NET server controls within XML (like http://www.dnzone.com/ShowDetail.asp?NewsId=151)?
MASTER PAGE - NavMaster.master
<%@ Master Language="VB" CodeFile="NavMaster.master.vb" Inherits="NavMaster" Debug="True" %>
<!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>Nav MasterPage</title>
<link rel="stylesheet" type="text/css" media="screen" href="~/docs/css/screen.css" />
</head>
<body>
<form id="form1" runat="server">
<div id="wrapper">
<!-- Tab navigation -->
<div id="tabs">
<asp:Menu id="Menu2" runat="server"
StaticDisplayLevels="1"
StaticSubMenuIndent="1"
StaticMenuStyle-VerticalPadding="0"
Orientation="Horizontal"
StaticEnableDefaultPopOutImage="False"
StaticMenuItemStyle-HorizontalPadding="0" StaticMenuStyle-HorizontalPadding="0">
<Items>
<asp:MenuItem NavigateUrl="default.aspx" ImageUrl="~/images/gif/tab1_active.gif" />
<asp:MenuItem NavigateUrl="~/aboutus/aboutus.aspx" ImageUrl="~/images/gif/tab2_active.gif" />
<asp:MenuItem NavigateUrl="~/depts/depts.aspx" ImageUrl="~/images/gif/tab3_active.gif" />
</Items>
</asp:Menu>
</div><!-- end tabs -->
<div id="screenleft">
<asp:contentplaceholder
id="LeftColumn"
runat="server" />
</div><!-- end screenleft -->
<div id="content">
<!-- dynamic page title -->
<h1><asp:label id="lblPageTitle" runat="server" /></h1>
<br />
<hr class="navyblueline" />
<!-- breadcrumbs -->
<asp:SiteMapPath
id="SiteMapPath1"
Runat="Server" />
<br /><br />
<!-- page content -->
<asp:contentplaceholder
id="ContentColumn"
runat="server" />
</div><!-- end content -->
<div id="screenright">
<asp:ContentPlaceHolder
id="RightColumn"
runat="server">
<asp:Image
ID="Ad1"
ImageUrl="~/images/gif/ad1.gif"
Runat="Server" />
<br />
<asp:Image
ID="Ad2"
ImageUrl="~/images/gif/ad2.gif"
Runat="Server" />
</asp:ContentPlaceHolder>
</div><!-- end screenright -->
<div id="screenfooter">
This is the footer section
</div><!-- end screenfooter -->
</div><!-- end wrapper -->
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
</form>
</body>
</html>
SITEMAP - web.sitemap
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
<siteMapNode url="~/default.aspx" title="Home" description="Home">
<siteMapNode id="aboutus" url="~/aboutus/aboutus.aspx" title="About Us" description="About Us">
</siteMapNode>
<siteMapNode url="~/depts/depts.aspx" title="Departments" description="Departments">
</siteMapNode>
</siteMapNode>
</siteMap>
ASP.NET PAGE - default.aspx
<%@ Page Language="VB" MasterPageFile="~/NavMaster.master" AutoEventWireup="false" CodeFile="default.aspx.vb" Inherits="_default" title="Home Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="LeftColumn" Runat="Server">
<!-- Leftnav buttons go here -->
<div id="screenleftnav">
<div class="leftheader">About Us</div><!-- end leftheader -->
<ul>
<li><a href="">Button 1</a></li>
<li><a href="">Button 2</a></li>
<li><a href="">Button 3</a></li>
<li><a href="">more...</a></li>
</ul>
<div class="leftheader">Departments</div><!-- end leftheader -->
<ul>
<li><a href="">Button 4</a></li>
<li><a href="">Button 5</a></li>
<li><a href="">Button 6</a></li>
<li><a href="">more...</a></li>
</ul>
<br />
</div><!-- end screenleftnav -->
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentColumn" Runat="Server">
This is the main content section. This is where the XML/XSLT transformation will take place.
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="RightColumn" Runat="Server">
<div id="screenright">
This is the right content section.
</div><!-- end screenright -->
</asp:Content>
VB.NET PAGE - default.aspx.vb
Partial Class NavMaster
Inherits System.Web.UI.MasterPage
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
lblPageTitle.Text = SiteMap.CurrentNode.Description
End Sub
End Class
What I don't like about the Master Page Control so far is the size of the pages. I haven't even put any content on the main section of the page, and it's already 31043 bytes in size. What are some steps that I can take to optimize this site (i.e. caching)? Also, how should I go about creating and processing a form within a transformed page using the Master Page control? Should I use XForms (like http://www.w3schools.com/xforms/default.asp) or dynamic ASP.NET server controls within XML (like http://www.dnzone.com/ShowDetail.asp?NewsId=151)?
MASTER PAGE - NavMaster.master
<%@ Master Language="VB" CodeFile="NavMaster.master.vb" Inherits="NavMaster" Debug="True" %>
<!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>Nav MasterPage</title>
<link rel="stylesheet" type="text/css" media="screen" href="~/docs/css/screen.css" />
</head>
<body>
<form id="form1" runat="server">
<div id="wrapper">
<!-- Tab navigation -->
<div id="tabs">
<asp:Menu id="Menu2" runat="server"
StaticDisplayLevels="1"
StaticSubMenuIndent="1"
StaticMenuStyle-VerticalPadding="0"
Orientation="Horizontal"
StaticEnableDefaultPopOutImage="False"
StaticMenuItemStyle-HorizontalPadding="0" StaticMenuStyle-HorizontalPadding="0">
<Items>
<asp:MenuItem NavigateUrl="default.aspx" ImageUrl="~/images/gif/tab1_active.gif" />
<asp:MenuItem NavigateUrl="~/aboutus/aboutus.aspx" ImageUrl="~/images/gif/tab2_active.gif" />
<asp:MenuItem NavigateUrl="~/depts/depts.aspx" ImageUrl="~/images/gif/tab3_active.gif" />
</Items>
</asp:Menu>
</div><!-- end tabs -->
<div id="screenleft">
<asp:contentplaceholder
id="LeftColumn"
runat="server" />
</div><!-- end screenleft -->
<div id="content">
<!-- dynamic page title -->
<h1><asp:label id="lblPageTitle" runat="server" /></h1>
<br />
<hr class="navyblueline" />
<!-- breadcrumbs -->
<asp:SiteMapPath
id="SiteMapPath1"
Runat="Server" />
<br /><br />
<!-- page content -->
<asp:contentplaceholder
id="ContentColumn"
runat="server" />
</div><!-- end content -->
<div id="screenright">
<asp:ContentPlaceHolder
id="RightColumn"
runat="server">
<asp:Image
ID="Ad1"
ImageUrl="~/images/gif/ad1.gif"
Runat="Server" />
<br />
<asp:Image
ID="Ad2"
ImageUrl="~/images/gif/ad2.gif"
Runat="Server" />
</asp:ContentPlaceHolder>
</div><!-- end screenright -->
<div id="screenfooter">
This is the footer section
</div><!-- end screenfooter -->
</div><!-- end wrapper -->
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
</form>
</body>
</html>
SITEMAP - web.sitemap
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
<siteMapNode url="~/default.aspx" title="Home" description="Home">
<siteMapNode id="aboutus" url="~/aboutus/aboutus.aspx" title="About Us" description="About Us">
</siteMapNode>
<siteMapNode url="~/depts/depts.aspx" title="Departments" description="Departments">
</siteMapNode>
</siteMapNode>
</siteMap>
ASP.NET PAGE - default.aspx
<%@ Page Language="VB" MasterPageFile="~/NavMaster.master" AutoEventWireup="false" CodeFile="default.aspx.vb" Inherits="_default" title="Home Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="LeftColumn" Runat="Server">
<!-- Leftnav buttons go here -->
<div id="screenleftnav">
<div class="leftheader">About Us</div><!-- end leftheader -->
<ul>
<li><a href="">Button 1</a></li>
<li><a href="">Button 2</a></li>
<li><a href="">Button 3</a></li>
<li><a href="">more...</a></li>
</ul>
<div class="leftheader">Departments</div><!-- end leftheader -->
<ul>
<li><a href="">Button 4</a></li>
<li><a href="">Button 5</a></li>
<li><a href="">Button 6</a></li>
<li><a href="">more...</a></li>
</ul>
<br />
</div><!-- end screenleftnav -->
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentColumn" Runat="Server">
This is the main content section. This is where the XML/XSLT transformation will take place.
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="RightColumn" Runat="Server">
<div id="screenright">
This is the right content section.
</div><!-- end screenright -->
</asp:Content>
VB.NET PAGE - default.aspx.vb
Partial Class NavMaster
Inherits System.Web.UI.MasterPage
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
lblPageTitle.Text = SiteMap.CurrentNode.Description
End Sub
End Class