473,325 Members | 2,608 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,325 software developers and data experts.

Programmatically setting MasterPageFile for an @ Master

I'm looking to discover in what event I can programmatically set this.MasterPageFile for a master page.

Documentation states that this property must be set in the PreInit or before, but master pages don't have a PreInit event -- just an Init event.

So what event is available to a master page that comes before PreInit that can be used to programmatically set the MasterPageFile property?

Thanks in advance!

--
Greg Collins [Microsoft MVP]
Visit Brain Trove ( http://www.BrainTrove.com )
Oct 17 '06 #1
3 4169
Perhaps I'm reading this wrong, but wouldn't/couldn't you set this in a page
and inherit it?

For example, if you have a BasePage that all of your other pages inherits.

~/App_Data/BasePage.cs contains:

public class BasePage : Page
{

public BasePage() : base()
{
base.PreInit += new EventHandler(Page_PreInit);
}

protected void Page_PreInit(object sender, EventArgs e)
{

this.MasterPageFile = "~/MasterPage.master";
}

---

~/Default.cs (code-behind for Default.aspx) contains the simple inheritance
of your BasePage:

public partial class _Default : BasePage
{

%code behind code%

}

---

Hope that helps or is what you're looking for. (^_^)

-dl
--
David Longnecker
Web Developer
http://blog.tiredstudent.com
I'm looking to discover in what event I can programmatically set
this.MasterPageFile for a master page.

Documentation states that this property must be set in the PreInit or
before, but master pages don't have a PreInit event -- just an Init
event.

So what event is available to a master page that comes before PreInit
that can be used to programmatically set the MasterPageFile property?

Thanks in advance!

Oct 17 '06 #2
"David R. Longnecker" <dl*********@community.nospamwrote in message
news:a0*************************@msnews.microsoft. com...
Perhaps I'm reading this wrong, but wouldn't/couldn't you set this in a
page and inherit it?
Yep - that's definitely the way to do it...
Oct 17 '06 #3
Thanks, I'll check it this out.

--
Greg Collins [Microsoft MVP]
Visit Brain Trove ( http://www.BrainTrove.com )
Oct 17 '06 #4

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

Similar topics

4
by: reezaali | last post by:
Hi All, I wanted to set up my websites like this c:\websites\intranettemplate c:\websites\app1 c:\websites\app2 Basically I wanted to have the master pages defined in the template folder...
2
by: Brian Orrell | last post by:
I have set the masterPageFile property in my web.config as follows: <pages masterPageFile="~/Main.master" > When I create a webform and I don't specify a masterPageFile in the aspx (so that it...
1
by: Alan Silver | last post by:
Hello, I have a site that uses master pages. To enable simple switching of the master page, and to avoid potential inconsistencies between pages, I set the master page file in the web.config...
2
by: dotnetjose | last post by:
Hi Folks, My subject message pretty musch explains it. By Default the Form definition sits at the Master Page file. Is there a way I can access the setting from my Content Page that uses a...
1
by: Joey | last post by:
Hello, I have tried to programmatically set the theme for my master page by putting code in a "Page_PreInit" fuction in the master page's code behind. However, when I set a breakpoint there and...
1
by: Amit Bansal \(MCT, MCSD.NET\) | last post by:
the msdn documentation says that if we can do application level binding by specifying the masterpagefile attribute in web.config, so that all the pages in the application are bound to a master...
3
by: Laith Zraikat | last post by:
I need to set the page title for a content page in a master page, and do that using local reources so that I can have my page title in different languages. I can do that easily using global...
3
by: Mike P | last post by:
How do you set the title of content pages? I can set the title of my master pages, but I want each of my content pages to have a different title. *** Sent via Developersdex...
4
by: Phil | last post by:
Hi, How to add programmatically a label into a content page? I tried this but doesn't work: Thanks Phil content page:
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.