Two Master Pages (C#) : Master page « User Control and Master Page « ASP.Net

Home
ASP.Net
1.ADO.net Database
2.Ajax
3.Asp Control
4.Collections
5.Components
6.Data Binding
7.Development
8.File Directory
9.HTML Control
10.Language Basics
11.Login Security
12.Mobile Control
13.Network
14.Page
15.Request
16.Response
17.Server
18.Session Cookie
19.Sitemap
20.Theme Style
21.User Control and Master Page
22.Validation by Control
23.Validation by Function
24.WebPart
25.WPF
26.XML
ASP.Net » User Control and Master Page » Master page 
Two Master Pages (C#)

<%@ page language="C#" MasterPageFile="main.master" printcontent:MasterPageFile="print.master" %>

<script runat="server" language="c#">

  public override bool TestDeviceFilter(string deviceFilterName) {

    if (deviceFilterName.Equals("printcontent")) {
        if (this.Request.QueryString["print"!= null) {
            return true;
        }
    }
    return base.TestDeviceFilter(deviceFilterName);
  }

</script>
<asp:content id="Content1" contentplaceholderid="ContentPlaceHolder1" runat="server">
    Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test
    Test Test<br />
    <br />
    <asp:hyperlink id="HyperLink1" runat="server" navigateurl="TwoMasterPages.aspx?print=1">Print
        me!</asp:hyperlink>
</asp:content>

<%-- main.master

<%@ master language="C#" %>

<script runat="server">

</script>

<html>
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form runat="server">
        <asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
        </asp:contentplaceholder>
    </form>
</body>
</html>

--%>

<%-- print.master

<%@ master language="C#" %>

<script runat="server">

</script>

<html>
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form runat="server">
        This master can be used for printing.<br />
        <br />
        <asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
        </asp:contentplaceholder>
    </form>
</body>
</html>

--%>
           
       
Related examples in the same category
1.Nested master page (C#)
2.Use master page (C#)
3.Master page with trace (C#)
4.Link content page with master page
5.Master page with Default Content
6.Master in page derivative
7.Two pieces of contentplaceholder
8.master for print
9.Control title in master page with content page code
10.Nested master page
11.Use image to fill the filler in master page
12.Code behind and master page
13.Specifying master page in Web.config causes every content page to inherit from the master page
14.Specifying the master page for a specific folder in the Web.config file: Use
15.A master page that creates a GUID on the first request (C#)
16.A master page that creates a GUID on the first request (VB)
17.A master page that exposes a custom property (C#)
18.A master page that exposes a custom property (VB)
19.Exposing a server control from a master page as a public property (C#)
20.Exposing a server control from a master page as a public property (VB)
21.Overriding some default content in the content page (C#)
22.Overriding some default content in the content page (VB)
23.Using Page_PreInit to assign the master page programmatically (C#)
24.Using Page_PreInit to assign the master page programmatically (VB)
25.A content page that can work with more than one master page
26.Update the page properties in master page
27.Nested master
28.Put site navigation in the master page
29.Master pages exposing an object model for content pages to programmatically modify elements on the master.
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.