473,386 Members | 1,609 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

asp.net 2.0 Master Page

Hello,

Currently I am using the following:
<%@ Page Language="VB" StylesheetTheme="Default"
MasterPageFile="~/template/mpColumn02.master" CodeFile="custrev.aspx.vb"
Inherits="custrev" title="Untitled Page" Trace="false" %>

Is there any way to pragmatically change the MasterPageFile? I need to
create a printer friendly link. With the link changing the MasterPageFile
from MasterPageFile01 to MasterPageFile02. Any help with this would be
appreciated...
--
Thanks in advance,

sck10
Jun 1 '06 #1
4 1419
Yep -- there's an event called Page_PreInit that's designed specifically
to change the MasterPageFile dynamically.

-Brock
http://staff.develop.com/ballen

Hello,

Currently I am using the following:
<%@ Page Language="VB" StylesheetTheme="Default"
MasterPageFile="~/template/mpColumn02.master"
CodeFile="custrev.aspx.vb"
Inherits="custrev" title="Untitled Page" Trace="false" %>
Is there any way to pragmatically change the MasterPageFile? I need
to create a printer friendly link. With the link changing the
MasterPageFile from MasterPageFile01 to MasterPageFile02. Any help
with this would be appreciated...

sck10

Jun 1 '06 #2
Hi,

What I do is pass a querystring value to indicate that the user has clicked
the print-friendly link. I detect that in the pre_init event and change the
master there. Here's some VB code:

Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As
System.EventArgs)
If Request("pr") = "1" Then
Me.Page.MasterPageFile = "print.master"
End If
End Sub
Here's a C# version:

protected void Page_PreInit(object sender, EventArgs e)
{
if (Request["pf"] == "1")
{
Page.MasterPageFile = "printfriendly.master";
}
}

Does this help?

Ken
Microsoft MVP [ASP.NET]
"sck10" <sc***@online.nospam> wrote in message
news:eH**************@TK2MSFTNGP03.phx.gbl...
Hello,

Currently I am using the following:
<%@ Page Language="VB" StylesheetTheme="Default"
MasterPageFile="~/template/mpColumn02.master" CodeFile="custrev.aspx.vb"
Inherits="custrev" title="Untitled Page" Trace="false" %>

Is there any way to pragmatically change the MasterPageFile? I need to
create a printer friendly link. With the link changing the MasterPageFile
from MasterPageFile01 to MasterPageFile02. Any help with this would be
appreciated...
--
Thanks in advance,

sck10

Jun 1 '06 #3
Thanks Ken,

Works great...

"Ken Cox [Microsoft MVP]" <BA**********@newsgroups.nospam> wrote in message
news:u3**************@TK2MSFTNGP02.phx.gbl...
Hi,

What I do is pass a querystring value to indicate that the user has
clicked the print-friendly link. I detect that in the pre_init event and
change the master there. Here's some VB code:

Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As
System.EventArgs)
If Request("pr") = "1" Then
Me.Page.MasterPageFile = "print.master"
End If
End Sub
Here's a C# version:

protected void Page_PreInit(object sender, EventArgs e)
{
if (Request["pf"] == "1")
{
Page.MasterPageFile = "printfriendly.master";
}
}

Does this help?

Ken
Microsoft MVP [ASP.NET]
"sck10" <sc***@online.nospam> wrote in message
news:eH**************@TK2MSFTNGP03.phx.gbl...
Hello,

Currently I am using the following:
<%@ Page Language="VB" StylesheetTheme="Default"
MasterPageFile="~/template/mpColumn02.master" CodeFile="custrev.aspx.vb"
Inherits="custrev" title="Untitled Page" Trace="false" %>

Is there any way to pragmatically change the MasterPageFile? I need to
create a printer friendly link. With the link changing the
MasterPageFile from MasterPageFile01 to MasterPageFile02. Any help with
this would be appreciated...
--
Thanks in advance,

sck10


Jun 2 '06 #4
In article <eH**************@TK2MSFTNGP03.phx.gbl>, sck10
<sc***@online.nospam> writes
I need to create a printer friendly link


In that case you would be far better off learning CSS and writing a
stylesheet that formats the page for a printer. The idea of having a
separate "printer friendly" version of a page went out years ago.
There's no reason to do it nowadays.

--
Alan Silver
(anything added below this line is nothing to do with me)
Jun 5 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Michael Herman \(Parallelspace\) | last post by:
1. What are some compelling solutions for using Master/Content pages with Web Pages? 2. If a content area has a web part zone with web parts, what is the user experience like when "editting" the...
2
by: Jon Spivey | last post by:
Hi, Using VS 2005/VB.net. I need to add a meta description tag and change a stylesheet link from a page based on a master page. Found this article...
3
by: ivanpais | last post by:
Hi, I have a Web User Control, Lets say "Foo.ascx", that contains a button "btnFoo". I have a Master Page "Bar.master", that has a label "lblBar". This label is exposed by a public property...
17
by: Rob R. Ainscough | last post by:
Again another simple concept that appears NOT to be intuitive or I'm just stupid. I've read the WROX book and the example doesn't actually show how the .master page links in the other content...
2
by: SR | last post by:
I have started a web site using ASP.NET 2.0. I would like to centralize all of my classes in a StyleSheet but I cannot figure out how to link the StyleSheet to a Content Page since there is no...
0
by: Managed Code | last post by:
Hello All, Here is my issue and thanks in advance for any assistance. I have a base page with a dropdownlist that fires an event with the selected index. The content page catches the event and...
4
by: Boris Yeltsin | last post by:
OK, on my Master Page I have a control: <a id="hypTabAccount" href="#" runat="server">Account</a> Now, in the code-behind (Root.master.vb) I can refer to it simply thus: ...
7
by: Just Me | last post by:
Hi I have a master page with a control on it, but I need to set a property of that control from the content. my master page is called Admin.Master and the class is Admin. I have tried this
6
by: =?Utf-8?B?SmF5IFBvbmR5?= | last post by:
I am trying to access a Public property on a Master Page from a Base Page. On the content pages I have the MasterType Directive set up as follows: <%@ MasterType virtualpath="~/Master.master" %>...
5
by: =?Utf-8?B?bXVzb3NkZXY=?= | last post by:
Hi guys I'm trying to make my code as streamlined as possible, and add CSS file references dynamically when they are required, for example, if a page contains a webcontrol, then the related CSS...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.