MasterPage Example in ASP.NET using C#

MasterPage Example in ASP.NET using C#


Posted in : ASP.Net Posted on : December 13, 2010 at 6:33 PM Comments : [ 0 ]

In this article we will introduce with MasterPage control in ASP.NET using C#.

Master Page Example in ASP.NET using C#

In this tutorial we will discuss how can We create Master Page in your application. Master page is different from simple web page. You can inherit master page in simple web page but you can't inherit simple web page to another page. There are the following step to create master page.

Step 1. Add Master Page in your project.

Step 2. The source code will look like this.

MasterPageSample.master (Design Page):

MasterPageSample.master (source code):

View source code Click Here

Now Add simple web page in your application and enable Select Master Page and click ADD. You can see the following figure.

Now open a window for select Master Page. You can select master page from in it and click OK.

Now the source code of Default Page look like this.

Default.aspx (Design Page):

Default.aspx (source code):

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPageSample.master" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<style type="text/css">
.style10
{
width: 100%;
}
.style11
{
font-size: xx-large;
color: #FF0000;
}
.style12
{
font-family: Cambria;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<table cellpadding="0" cellspacing="0" class="style10">
<tr>
<td style="text-align: center; vertical-align: top; right: 10px; left: 10px">
<p class="style11">
Welcome to devmanuals.com</p>
<p class="style12">
DevManuals.com is technical resource for the web site developers, programmers, designers,
database administrators and technical managers. On this website we are providing
articles, tutorials, examples and tips on many programming languages and programming
technologies. Here you will find technical stuff's on HTML, DHTML, CSS, Java, JSP,
Servlets, Ajax, jQuery and many other technologies. These tutorials will help you
in getting started with programming and web development technologies. The getting
started guide will help you in learning the basic concepts easily and quickly. We
hope tutorials provided here will help you in learning various programming technologies.
</p>
</td>
</tr>
</table>
<asp:BulletedList ID="BulletedList1" runat="server" BulletImageUrl="~/Images/bullet-red.png"
BulletStyle="CustomImage" Font-Bold="True" Font-Names="Courier New" Font-Size="X-Large"
ForeColor="Blue" DisplayMode="HyperLink">
<asp:ListItem Value="http://www.devmanuals.com/">CORE JAVA</asp:ListItem>
<asp:ListItem Value="http://www.devmanuals.com/">SERVLET</asp:ListItem>
<asp:ListItem Value="http://www.devmanuals.com/">JSP</asp:ListItem>
<asp:ListItem Value="http://www.devmanuals.com/">ASP.NET</asp:ListItem>
<asp:ListItem Value="http://www.devmanuals.com/">FLEX</asp:ListItem>
<asp:ListItem Value="http://www.devmanuals.com/">HTML</asp:ListItem>
</asp:BulletedList>
</asp:Content>

Output:

Download source code
Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics