Articles → .NET → Page Template in .net 1.1

Page Template in .net 1.1
























Software requirement





Prerequisite knowledge















Creation of base class






using System;
using System.Web.UI;

public class PageBase : System.Web.UI.Page
{
    private string _pageTitle;
    public string PageTitle
    {
        get { return _pageTitle; }
        set { _pageTitle = value; }
    }

    protected override void Render(HtmlTextWriter writer)
    {
        // First we will build up the html document, 
        // the head section and the body section.
        writer.Write(@"
            <html>
                <head>
                    <title>" + PageTitle + @"</title>
                </head>
                <body>");

        // Then we allow the base class to render the 
        // controls contained in the ASPX file.
        base.Render(writer);

        // Finally we render the final tags to close
        // the document.
        writer.Write(@"
                </body>
            </html>");
    }
}





Create a web page


<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<form id="SimplePageInheritance" method="post" runat="server">    
    <p>
        This is the sample of the page with master page like feature 
        without using master page.
    </p>
</form>




using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        PageTitle = "test";
    }
}





Output



Click to Enlarge


Conclusion





Posted By  -  Karan Gupta
 
Posted On  -  Wednesday, September 15, 2010

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250