Logo
  
asp.net hosting DotNet Hosting  eCommerce Hosting  SQL Server Hosting  ADO DotNet  ASP DotNet  DotNet Tutorials 
  
         
 

Your domain available ?
www.

BUY NOW
ASPNET 4
SQL SERVER HOSTING
SQL SERVER 2012 HOSTINGNew
DOTNETNUKE HOSTING
GET LISTED IN GOOGLE
30 DAY MONEY BACK
OUR PARTNERS
ASP NET TUTORIALS
WEB DESIGN TEMPLATES
TERMS
PRESS ROOM
CONTACT US




 

 

ASP.NET 2.0 Master Pages

« ASP.NET 2.0 Tutorials Index

ASP.NET 2.0 has a new Master Page feature. This feature provides the ability to define common structure and interface elements for your site like a template, such as a page header, footer, or navigation bar, in a common location called a "master page", to be shared by many pages in your site. Master Pages improve the maintainability of your site and avoids unnecessary duplication of code for shared site structure or behaviour.

Master Pages are a must have for large web-sites.

Code:

GB.master

<%@ Master Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">


Public Property CompanyName() As String
Get
     Return CType(ViewState("companyName"), String)
End Get
Set(ByVal Value As String)
     ViewState("companyName") = Value
End Set
End Property

Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs) _
Handles Me.Init
     Me.CompanyName = "DotNet-Webhosting.com"
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Master Page Tutorial</title>
</head>
<body bgcolor="#99cccc">
<form id="form1" runat="server">
<div>
&nbsp;<table border="0" cellpadding="0" cellspacing="0" style="width: 100%; height: 100%">
<tr>
<td colspan="2" bgcolor="#ffffff" height="48">
<asp:Menu ID="Menu1" runat="server">
<Items>
<asp:MenuItem NavigateUrl="home.aspx" Text="Home" Value="Home"></asp:MenuItem>
</Items>
</asp:Menu>
</td>
</tr>
<tr>
<td bgcolor="#ffffff" height="48" valign="top" width="28">
</td>
<td bgcolor="#ffffff" valign="top">
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
</td>
</tr>
<tr>
<td bgcolor="#ffffff" height="48" colspan="2" valign="top" align="center">
Copyright DotNet-Webhosting.com</td>
</tr>
</table>
</div>
</form>
</body>
</html>

 

Content Page: Home.aspx

<%@ Page Language="VB" MasterPageFile="~/GB.master" Title="Untitled Page" %>
<%@ MasterType virtualpath="~/GB.master" %>

<script runat="server">

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
lblCompany.Text = Master.CompanyName
End Sub
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<h1>
Welcome to:
<asp:Label ID="lblCompany" runat="server" Text="Label"></asp:Label></h1>
<p>
ASP.NET 2.0 Mater pages demo</p>

<br />
</asp:Content>

 

 

Author: Roger Bert
Outsource-Solutions.co.uk

 

 

 

 

 

  asp.net 2.0 sql server 2005


Terms   Privacy

Copyright ©2002-2011 DotNet We Hosting UK, All rights reserved