CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 9/28/2006 5:09:14 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 7 Views: 16 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
8 Items, 1 Pages 1 |< << Go >> >|
just_for_forums
Asp.Net User
Do Masterpages have a preinit event?9/28/2006 5:09:14 PM

0/0

I have this code:

1    public partial class MasterPage : System.Web.UI.MasterPage
2    {
3        protected void Page_Load(object sender, EventArgs e)
4        {
5            if (!IsPostBack)
6            {
7                Label1.Text = Profile.FullName;
8            }
9        }
10       protected void Page_PreInit(object sender, EventArgs e)
11       {
12           Response.Write("HI");
13           Page.Theme = Profile.MyTheme;
14       }
15   }

 

If Masterpages do not have the preinit event, then how can I set the theme dynamically for all my pages that are based upon the single Masterpage?

Thank you for any help. 

 

lostlander
Asp.Net User
Re: Do Masterpages have a preinit event?9/29/2006 1:56:45 AM

0/0

Masterpage doesn't have PreInit method.

There are several alternatives you can adopt.

1, Create a common base page class for all other pages to inherit, set the theme property in that class;
http://www.odetocode.com/Articles/450.aspx

2, Set the global theme in web.config:
<configuration>
    <system.web>
        <pages theme="ThemeName" />
    </system.web>
</configuration>
http://msdn2.microsoft.com/en-us/library/0yy5hxdk.aspx

Regards.
lostlander.

PaxGalactica
Asp.Net User
Re: Do Masterpages have a preinit event?9/29/2006 6:33:21 AM

0/0

I need to do this very thing as well: using master pages with dynamically chosen themes. And it can be done. While the master page object may not have the Page_PreInit() method, the content page object does! So, if I had two files "Pgo.master" and "Default.aspx" with the aspx page using the master page, the "Default.aspx.cs" file (I like using code-behind) could have code something like this:

(C# code)
public partial class _Default : System.Web.UI.Page
{
   protected void Page_Load(object sender, EventArgs e)
   {
      // Just to show the page title being changed too.
      Page.Header.Title = "Pax Galactica Online";
   }

   protected void Page_PreInit(object sender, EventArgs e)
   {
      // The page theme is dynamically updated here
      Page.Theme = Profile.MyTheme;
   }

}

PaxGalactica
Asp.Net User
Re: Do Masterpages have a preinit event?9/29/2006 6:51:52 AM

0/0

I almost forgot to mention this. The original poster asked

    "If Masterpages do not have the preinit event, then how can I set the theme dynamically for all my
     pages that are based upon the single Masterpage?"

The question points out something which can be misleading. Master pages are not objects from which pages that use them are derived. Rather, think of master pages as formatting files. The content pages are the top-level objects, with the "master" page being just an example of how you want the web server to render the common elements among your pages.

An important result of this then is that all code that is not common to all pages should be placed in the content pages, not in the master page(s). The content pages are actual Page objects, so they have all the methods and proprties of "stand-alone" Page objects (those not using master pages).

Some New Guy
http://www.paxgalacticaonline.com/

just_for_forums
Asp.Net User
Re: Do Masterpages have a preinit event?10/2/2006 5:23:55 PM

0/0

PaxGalactica:

I need to do this very thing as well: using master pages with dynamically chosen themes. And it can be done. While the master page object may not have the Page_PreInit() method, the content page object does! So, if I had two files "Pgo.master" and "Default.aspx" with the aspx page using the master page, the "Default.aspx.cs" file (I like using code-behind) could have code something like this:

(C# code)
public partial class _Default : System.Web.UI.Page
{
   protected void Page_Load(object sender, EventArgs e)
   {
      // Just to show the page title being changed too.
      Page.Header.Title = "Pax Galactica Online";
   }

   protected void Page_PreInit(object sender, EventArgs e)
   {
      // The page theme is dynamically updated here
      Page.Theme = Profile.MyTheme;
   }

}

 

This means I need it in every single .aspx page.  Correct?  What if it is an existing site with hundreds of pages?

just_for_forums
Asp.Net User
Re: Do Masterpages have a preinit event?10/2/2006 5:23:55 PM

0/0

PaxGalactica:

I need to do this very thing as well: using master pages with dynamically chosen themes. And it can be done. While the master page object may not have the Page_PreInit() method, the content page object does! So, if I had two files "Pgo.master" and "Default.aspx" with the aspx page using the master page, the "Default.aspx.cs" file (I like using code-behind) could have code something like this:

(C# code)
public partial class _Default : System.Web.UI.Page
{
   protected void Page_Load(object sender, EventArgs e)
   {
      // Just to show the page title being changed too.
      Page.Header.Title = "Pax Galactica Online";
   }

   protected void Page_PreInit(object sender, EventArgs e)
   {
      // The page theme is dynamically updated here
      Page.Theme = Profile.MyTheme;
   }

}

 

This means I need it in every single .aspx page.  Correct?  What if it is an existing site with hundreds of pages?

 
just_for_forums
Asp.Net User
Re: Do Masterpages have a preinit event?10/2/2006 5:24:07 PM

0/0

PaxGalactica:

I need to do this very thing as well: using master pages with dynamically chosen themes. And it can be done. While the master page object may not have the Page_PreInit() method, the content page object does! So, if I had two files "Pgo.master" and "Default.aspx" with the aspx page using the master page, the "Default.aspx.cs" file (I like using code-behind) could have code something like this:

(C# code)
public partial class _Default : System.Web.UI.Page
{
   protected void Page_Load(object sender, EventArgs e)
   {
      // Just to show the page title being changed too.
      Page.Header.Title = "Pax Galactica Online";
   }

   protected void Page_PreInit(object sender, EventArgs e)
   {
      // The page theme is dynamically updated here
      Page.Theme = Profile.MyTheme;
   }

}

 

This means I need it in every single .aspx page.  Correct?  What if it is an existing site with hundreds of pages?

 Thanks.
bitmask
Asp.Net User
Re: Do Masterpages have a preinit event?10/2/2006 6:24:14 PM

0/0

just_for_forums:

This means I need it in every single .aspx page.  Correct?  What if it is an existing site with hundreds of pages?

An alternative is to use an HttpModule and hook the PreInit event of a page.

See my articles: Taking Care of PreInit and Master Pages: Tips, Tricks, Traps.

8 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Professional ASP.NET 3.5: In C# and VB Authors: Bill Evjen, Scott Hanselman, Devin Rader, Pages: 1673, Published: 2008
Professional ASP.NET 2.0 Design: CSS, Themes, and Master Pages Authors: Jacob J. Sanford, Pages: 474, Published: 2007
Essential ASP.Net 2.0 Authors: Fritz Onion, Keith Brown, Pages: 345, Published: 2006
ASP.NET 2.0: A Developer's Notebook Authors: Wei Meng Lee, Pages: 326, Published: 2005
ASP.NET 2.0 Cookbook Authors: Michael A. Kittel, Geoffrey T. Leblond, Pages: 989, Published: 2005
ASP.NET 2.0 Website Programming: Problem-design-solution Authors: Marco Bellinaso, Pages: 576, Published: 2006
Pro ASP.NET 2.0 Website Programming Authors: Damon Armstrong, Pages: 641, Published: 2005
ASP.NET 2.0: Your Visual Blueprint for Developing Web Applications Authors: Chris Love, Pages: 339, Published: 2007
Expert ASP.NET 2.0 Advanced Application Design: Advanced Application Design Authors: Dominic Selly, Andrew Troelsen, Tom Barnaby, Pages: 459, Published: 2005
A First Look at ASP.NET V. 2.0 Authors: Alex Homer, Dave Sussman, Rob Howard, Pages: 528, Published: 2004

Web:
Do Masterpages have a PreInit event? Talk about Do Masterpages have a PreInit event? ... Default Do Masterpages have a PreInit event? I have this code. The preinit never fires: ...
Do Masterpages have a preinit event? - ASP.NET Forums If Masterpages do not have the preinit event, then how can I set the theme dynamically for all my pages that are based upon the single ...
What is pre-init event in ASP.NET 2.0 page life cycle? So PreInit() in the Page is the first event to fire but User Controls or MasterPage (which is itself a Usercontrol) do not have any PreInit event . ...
ASP.Net 2.0 - Master Pages: Tips, Tricks, and Traps Apr 11, 2006 ... All of this work occurs after the content page’s PreInit event, ..... Handle the Click event in the master page, and have the master page ...
Master Pages vs. Themes: Which Do You Choose? Do you plan on having a collection of sites and each site needs to have its own color .... PreInit event handler. Hope this helps... re: Master Pages vs. ...
Master Pages When it comes time for the master page to do its job, the master page replaces the ... All of this work occurs after the content page’s PreInit event, ...
Anyone Setting Themes from Master Page it appears that Master pages do not have PreInit events. > > I REALLY do not want to have to stick the same code in each and every page I ...
Dynamic Themes and META Data using ASP.NET 2.0 Master Pages May 17, 2007 ... NET Web Form very early in execution, so you must do so before the Page initializes. This is typically handled in a PreInit event handler ...
Working With Master Page - Vikram Lakhotia We can specift the master page for the webform in the web.config, @pagedirective or the preInit event. We have to use the MasterPageFile ...
Customizing and Managing Your Site's Appearance / Part 3 This occurs after the PreInit event but before the Init event of the page. Like any control, master pages have their own sequence of events that are fired ...




Search This Site:










links1 links2 (having both horiz. and vert menus)

posting guidlines for this sub forum

placing a link in the html/text module

same look across all browsers and different screen resolution

add third party control in dotnetnuke_2.1.2

check for bad links

change login page at runtime

displaying a gridview in the content page from the menu control in the master page !!!

using/adding existing usercontrols in dnn

how to build master webcontrol

missing usernamerecovery control

changing privacy statement

"page.clientscript" does not compile in assembly

having a showstopper problem w/magic gadget...

upgrading tests ...

sitemap and security trimming problem

disable caching on menu control

encrypt web.config-sections; how to get the virtualpath from a webapplication?

gridview layout

cookie question about ibuyspy login page

toolbox doesn't contain web controls

default view rights of new pages and modules

how can i load this in vs 2005?

ibuyspy sub tabs

help me convert this c# code

how to convert the aspnetsecurity.sql for oracle

how do i get around an error when binding a checkbox to an empty data source?

login

i need to change the cirtual path when debuggin or viewing asp.net site

problem with editurl

 
All Times Are GMT