Asp.Net Tutorial and Assignment no 9 for Beginner Create Master Page in ASP.net

ASP.net Master pages enable to create a perfect and consistent look, behavior for all the web pages in your web application. The content pages contain the content you want to display.

A master webpage provides a template for other web pages, with shared layout design and functionality of master design. The master page defines placeholders for the content, which can be overridden by content pages. The output result is a combination of the master page and the content page.

When users request the content page, ASP.NET merges the pages to produce output that combines the layout of the master page with the content of the content page.

[LinkVer]

Must Read : How To Spy on Girlfriend / Boyfriend Whatsapp Account

Must Read: Install Whatsapp with Rooted Andriod Phone

Lecture 5

Asp.Net Programming Assignment no 9 – ASP Tutorial for Beginners Create Master Page in ASP.net

[ResponsiveRect]

Objective:

Create a Master page which display current date as soon as form is loaded and provide some link to display another page, apply it to another web page.

Controls, Methods, Properties & Event Used:

  1. Master Page
  2. Label
  3. Hyper Link

Output:

ASP.net Tutorial Create Master Page

Program:

Copy and Paste the Code in ASP.net

// In Master Page Source //
<html xmlns=”http://www.w3.org/1999/xhtml” >
<head runat=”server”>
<title>Untitled Page</title>
<style>
body
{
font-family:verdana; font-size:10pt;
}
.textboxStyle
{
border: 1px solid silver; font-size:8pt; color:grey;
font-family:verdana
}
.buttonStyle
{
border:1px solid black; background-color:
silver;font-size:8pt;font-family:verdana;
}
</style>
</head>
<body leftmargin=”0″ topmargin=”0″>
<form id=”form1″ runat=”server”>
<div>
<table border=”0″ cellpadding=”0″ cellspacing=”0″ style=”width: 750px”>
<tr>
<td align=”left” colspan=”1″ style=”height:100px; background-color: #ffffff; border-bottom: solid thin black;” valign=”top”>
<asp:Image ID=”Image1″ runat=”server” Height=”80px” ImageUrl=”~/images/4.jpg” Width=”120px” /></td>
<td align=”left” colspan=”2″ style=”height:100px;border-bottom: solid thin black;” valign=”top”>
<br />
<strong><h3>ASP.NET Lecture</h3>
<p>
<asp:Label ID=”Label1″ runat=”server”></asp:Label>&nbsp;</p>
</strong></td>
</tr>
<tr>
<td style=”width: 180px; height: 400px;background-color: #ffffcc;” valign=”top”>
<br />
<asp:HyperLink ID=”HyperLink1″ runat=”server” NavigateUrl=”~/frmDropdownListExample.aspx”>Dropdownlist Example</asp:HyperLink><br />
<asp:HyperLink ID=”HyperLink2″ runat=”server” NavigateUrl=”~/frmCheckBoxExample.aspx”>CheckBox Example</asp:HyperLink><br />
<asp:HyperLink ID=”HyperLink3″ runat=”server” NavigateUrl=”~/frmValidationControlsExample.aspx”>Validation Example</asp:HyperLink><br />
<asp:HyperLink ID=”HyperLink4″ runat=”server” NavigateUrl=”~/Default3.aspx”>Register
User</asp:HyperLink><br />
<asp:HyperLink ID=”HyperLink5″
runat=”server” NavigateUrl=”~/frmMasterPageExample.aspx”>Master page example 1</asp:HyperLink><br />
<asp:HyperLink ID=”HyperLink6″
runat=”server” NavigateUrl=”~/frmMasterpageExample2.aspx”>Master page example 2</asp:HyperLink></td>
<td colspan=”2″ style=”width: 570px; height:400px” valign=”top”>
<div style=”margin-left:25px; margintop:25px;”>
<asp:ContentPlaceHolderID=”ContentPlaceHolder1″ runat=”server”>
</asp:ContentPlaceHolder>
</div>
</td>
</tr>
<tr>
<td colspan=”3″ style=”border-top: solid thin
black;”>
&copy; 2008 ASPLecture</td>
</tr>
</table>
</div>
</form>
</body>
</html>

AD [ResponsiveRect]

// In Master Page .cs File //
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class MasterPage : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = DateTime.Now.ToString(“dd-MMM”);
}
}

// In .Aspx Source //
<%@ Page Language=”C#” MasterPageFile=”~/MasterPage.master” AutoEventWireup=”true” CodeFile=”frmMasterPageExample.aspx.cs” Inherits=”frmMasterPageExample” Title=”Untitled Page” %>
<asp:Content ID=”Content1″ ContentPlaceHolderID=”ContentPlaceHolder1″ Runat=”Server”>
<br />
&nbsp;<asp:Image ID=”Image1″ runat=”server” ImageUrl=”~/images/graphic_design.jpg” />
</asp:Content>

Find More Tutorials Here

Find Tally Tutorial Here
Find Advance Excel Tutorial Here

Add a Comment

Your email address will not be published. Required fields are marked *