File: index.aspx
<%@ page language="C#" MasterPageFile="~/main.master" printcontent:master="~/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="Default.aspx?print=1">Print
me!</asp:hyperlink>
</asp:content>
File: main.master
<%@ master language="C#" %>
<html>
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form runat="server">
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server"/>
</form>
</body>
</html>
File: print.master
<%@ master language="C#" %>
<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"/>
</form>
</body>
</html>