Difference between Web Form and Web Form with Master Page?

Master pages permit you to make an identical look and behavior for all the pages (or cluster of pages) in your net application.

A master page provides a guide for alternative pages, with shared layout and practicality. The master page defines placeholders for the content, which may be overridden by content pages. The output result's a mixture of the master page and also the content page.

The content pages contain the content you wish to show.

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


Example master page:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="Site" %>

<!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>Working with Data Tutorials</title>
    <link href="Styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div id="wrapper">

        <form id="form1" runat="server">

            <div id="header">
                <span class="title">Working with Data Tutorials</span>
                <span class="breadcrumb">TODO: Breadcrumb will go here...</span>
            </div>

            <div id="content">
                <asp:contentplaceholder id="MainContent" runat="server">
                  <!-- Page-specific content will go here... -->
                </asp:contentplaceholder>
            </div>

            <div id="navigation">
                TODO: Menu will go here...
            </div>
        </form>
    </div>
</body>
</html>

Example content page:

<%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Title="Home" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
    <h1>Welcome to the Working with Data Tutorial Site</h1>

    <p>This site is being built as part of a set of tutorials that illustrate some of the new data access and databinding features in ASP.NET 2.0 and Visual Web Developer.</p>

<asp:TextBox runat="server" id="TextBox1" /><br />
<asp:TextBox runat="server" id="TextBox2" /><br />
<asp:Button runat="server" id="Btn1" OnClick="Btn1_Click" Text="Click to submit!" />

        </asp:Content>

On the code behind (.cs file) for the page, you'd read the values from the text boxes like this:

protected void Btn1_Click(object sender, EventArgs e)
{
    string sometext=TextBox1.Text;
    string somemoretext=TextBox2.Text;
}


Thank you for sharing Your Knowledge with others who need It.-Team LetML

1 comment :

  1. Poker Room - Las Vegas, NV Jobs | JamBase
    At 고양 출장샵 JamBase, every 순천 출장샵 casino game is 광주 출장마사지 guaranteed to bring fun to the table. It also offers fun VIP 이천 출장안마 promotions with our VIP Program. Learn 보령 출장마사지 more!

    ReplyDelete

Copyright © LetML. Blogger Templates Designed by OddThemes