<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Master Pages, Themes and Navigation Controls</title><link>http://forums.asp.net/139.aspx</link><description>Discussions of MasterPages, Themes, and other page-related features. &lt;A href="http://aspadvice.com/SignUp/list.aspx?l=164&amp;amp;c=30" target=_blank&gt;Email List&lt;/A&gt;</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: Do Masterpages have a preinit event?</title><link>http://forums.asp.net/thread/1416155.aspx</link><pubDate>Mon, 02 Oct 2006 18:24:14 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1416155</guid><dc:creator>bitmask</dc:creator><author>bitmask</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1416155.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=139&amp;PostID=1416155</wfw:commentRss><description>&lt;blockquote&gt;&lt;div&gt;&lt;img src="http://forums.asp.net/Themes/default/images/icon-quote.gif" /&gt; &lt;strong&gt;just_for_forums:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt; &lt;p&gt;This means I need it in every single .aspx page.&amp;nbsp; Correct?&amp;nbsp; What if it is an existing site with hundreds of pages? &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;p&gt;An alternative is to use an HttpModule and hook the PreInit event of a page. &lt;/p&gt;&lt;p&gt;See my articles: &lt;a href="http://odetocode.com/Blogs/scott/archive/2005/12/09/2604.aspx"&gt;Taking Care of PreInit&lt;/a&gt;&amp;nbsp;and &lt;a href="http://odetocode.com/Articles/450.aspx" target="_blank"&gt;Master Pages: Tips, Tricks, Traps&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Re: Do Masterpages have a preinit event?</title><link>http://forums.asp.net/thread/1416086.aspx</link><pubDate>Mon, 02 Oct 2006 17:24:07 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1416086</guid><dc:creator>just_for_forums</dc:creator><author>just_for_forums</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1416086.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=139&amp;PostID=1416086</wfw:commentRss><description>&lt;blockquote&gt;&lt;div&gt;&lt;img src="http://forums.asp.net/Themes/default/images/icon-quote.gif" /&gt; &lt;strong&gt;PaxGalactica:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt; &lt;p&gt;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 &amp;quot;Pgo.master&amp;quot; and &amp;quot;Default.aspx&amp;quot; with the aspx page using the master page, the &amp;quot;Default.aspx.cs&amp;quot; file (I like using code-behind) could have code something like this:&lt;/p&gt;&lt;p&gt;(C# code) &lt;br /&gt;public partial class _Default : System.Web.UI.Page&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Just to show the page title being changed too.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Page.Header.Title = &amp;quot;Pax Galactica Online&amp;quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp; protected void Page_PreInit(object sender, EventArgs e)&lt;br /&gt;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // The page theme is dynamically updated here&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Page.Theme = Profile.MyTheme;&lt;br /&gt;&amp;nbsp;&amp;nbsp; }&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;This means I need it in every single .aspx page.&amp;nbsp; Correct?&amp;nbsp; What if it is an existing site with hundreds of pages? &lt;/p&gt;&amp;nbsp;Thanks.</description></item><item><title>Re: Do Masterpages have a preinit event?</title><link>http://forums.asp.net/thread/1416084.aspx</link><pubDate>Mon, 02 Oct 2006 17:23:55 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1416084</guid><dc:creator>just_for_forums</dc:creator><author>just_for_forums</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1416084.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=139&amp;PostID=1416084</wfw:commentRss><description>&lt;blockquote&gt;&lt;div&gt;&lt;img src="http://forums.asp.net/Themes/default/images/icon-quote.gif" /&gt; &lt;strong&gt;PaxGalactica:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt; &lt;p&gt;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 &amp;quot;Pgo.master&amp;quot; and &amp;quot;Default.aspx&amp;quot; with the aspx page using the master page, the &amp;quot;Default.aspx.cs&amp;quot; file (I like using code-behind) could have code something like this:&lt;/p&gt;&lt;p&gt;(C# code) &lt;br /&gt;public partial class _Default : System.Web.UI.Page&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Just to show the page title being changed too.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Page.Header.Title = &amp;quot;Pax Galactica Online&amp;quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp; protected void Page_PreInit(object sender, EventArgs e)&lt;br /&gt;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // The page theme is dynamically updated here&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Page.Theme = Profile.MyTheme;&lt;br /&gt;&amp;nbsp;&amp;nbsp; }&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;This means I need it in every single .aspx page.&amp;nbsp; Correct?&amp;nbsp; What if it is an existing site with hundreds of pages? &lt;/p&gt;&amp;nbsp;</description></item><item><title>Re: Do Masterpages have a preinit event?</title><link>http://forums.asp.net/thread/1416083.aspx</link><pubDate>Mon, 02 Oct 2006 17:23:55 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1416083</guid><dc:creator>just_for_forums</dc:creator><author>just_for_forums</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1416083.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=139&amp;PostID=1416083</wfw:commentRss><description>&lt;blockquote&gt;&lt;div&gt;&lt;img src="http://forums.asp.net/Themes/default/images/icon-quote.gif" /&gt; &lt;strong&gt;PaxGalactica:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt; &lt;p&gt;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 &amp;quot;Pgo.master&amp;quot; and &amp;quot;Default.aspx&amp;quot; with the aspx page using the master page, the &amp;quot;Default.aspx.cs&amp;quot; file (I like using code-behind) could have code something like this:&lt;/p&gt;&lt;p&gt;(C# code) &lt;br /&gt;public partial class _Default : System.Web.UI.Page&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Just to show the page title being changed too.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Page.Header.Title = &amp;quot;Pax Galactica Online&amp;quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp; protected void Page_PreInit(object sender, EventArgs e)&lt;br /&gt;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // The page theme is dynamically updated here&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Page.Theme = Profile.MyTheme;&lt;br /&gt;&amp;nbsp;&amp;nbsp; }&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;This means I need it in every single .aspx page.&amp;nbsp; Correct?&amp;nbsp; What if it is an existing site with hundreds of pages? &lt;/p&gt;</description></item><item><title>Re: Do Masterpages have a preinit event?</title><link>http://forums.asp.net/thread/1413719.aspx</link><pubDate>Fri, 29 Sep 2006 06:51:52 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1413719</guid><dc:creator>PaxGalactica</dc:creator><author>PaxGalactica</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1413719.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=139&amp;PostID=1413719</wfw:commentRss><description>&lt;p&gt;I almost forgot to mention this. The original poster asked&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;quot;If Masterpages do&amp;nbsp;not have the preinit event, then how can I set the theme dynamically for all my&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pages that are based upon the single&amp;nbsp;Masterpage?&amp;quot;&lt;/p&gt;&lt;p&gt;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 &amp;quot;master&amp;quot; page being just an example of how you want the web server to render the common elements among your pages.&lt;/p&gt;&lt;p&gt;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 &amp;quot;stand-alone&amp;quot; Page objects (those not using master pages).&lt;/p&gt;&lt;p&gt;Some New Guy&lt;br /&gt;http://www.paxgalacticaonline.com/&lt;/p&gt;</description></item><item><title>Re: Do Masterpages have a preinit event?</title><link>http://forums.asp.net/thread/1413708.aspx</link><pubDate>Fri, 29 Sep 2006 06:33:21 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1413708</guid><dc:creator>PaxGalactica</dc:creator><author>PaxGalactica</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1413708.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=139&amp;PostID=1413708</wfw:commentRss><description>&lt;p&gt;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 &amp;quot;Pgo.master&amp;quot; and &amp;quot;Default.aspx&amp;quot; with the aspx page using the master page, the &amp;quot;Default.aspx.cs&amp;quot; file (I like using code-behind) could have code something like this:&lt;/p&gt;&lt;p&gt;(C# code) &lt;br /&gt;public partial class _Default : System.Web.UI.Page&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Just to show the page title being changed too.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Page.Header.Title = &amp;quot;Pax Galactica Online&amp;quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp; protected void Page_PreInit(object sender, EventArgs e)&lt;br /&gt;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // The page theme is dynamically updated here&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Page.Theme = Profile.MyTheme;&lt;br /&gt;&amp;nbsp;&amp;nbsp; }&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;</description></item><item><title>Re: Do Masterpages have a preinit event?</title><link>http://forums.asp.net/thread/1413529.aspx</link><pubDate>Fri, 29 Sep 2006 01:56:45 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1413529</guid><dc:creator>lostlander</dc:creator><author>lostlander</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1413529.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=139&amp;PostID=1413529</wfw:commentRss><description>&lt;p&gt;Masterpage doesn&amp;#39;t have PreInit method.&lt;/p&gt;&lt;p&gt;There are several alternatives you can adopt.&lt;/p&gt;&lt;p&gt;1, Create a common base page class for all other pages to inherit, set the theme property in that class;&lt;br /&gt;&lt;a href="http://www.odetocode.com/Articles/450.aspx"&gt;http://www.odetocode.com/Articles/450.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;2, Set the global theme in web.config: &lt;br /&gt;&amp;lt;configuration&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;system.web&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;pages theme=&amp;quot;ThemeName&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/system.web&amp;gt;&lt;br /&gt;&amp;lt;/configuration&amp;gt;&lt;br /&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/0yy5hxdk.aspx"&gt;http://msdn2.microsoft.com/en-us/library/0yy5hxdk.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Regards.&lt;br /&gt;lostlander.&lt;/p&gt;</description></item><item><title>Do Masterpages have a preinit event?</title><link>http://forums.asp.net/thread/1413051.aspx</link><pubDate>Thu, 28 Sep 2006 17:09:14 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1413051</guid><dc:creator>just_for_forums</dc:creator><author>just_for_forums</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1413051.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=139&amp;PostID=1413051</wfw:commentRss><description>&lt;p&gt;I have this code:&lt;/p&gt;&lt;pre class="coloredcode"&gt;&lt;strong id="1"&gt;1    &lt;/strong&gt;&lt;span class="kwd"&gt;public&lt;/span&gt; partial &lt;span class="kwd"&gt;class&lt;/span&gt; MasterPage : System.Web.UI.MasterPage
&lt;strong id="2"&gt;2    &lt;/strong&gt;{
&lt;strong id="3"&gt;3    &lt;/strong&gt;    &lt;span class="kwd"&gt;protected void&lt;/span&gt; Page_Load(&lt;span class="kwd"&gt;object&lt;/span&gt; sender, EventArgs e)
&lt;strong id="4"&gt;4    &lt;/strong&gt;    {
&lt;strong id="5"&gt;5    &lt;/strong&gt;        &lt;span class="kwd"&gt;if&lt;/span&gt; (!IsPostBack)
&lt;strong id="6"&gt;6    &lt;/strong&gt;        {
&lt;strong id="7"&gt;7    &lt;/strong&gt;            Label1.Text = Profile.FullName;
&lt;strong id="8"&gt;8    &lt;/strong&gt;        }
&lt;strong id="9"&gt;9    &lt;/strong&gt;    }
&lt;strong id="10"&gt;10   &lt;/strong&gt;    &lt;span class="kwd"&gt;protected void&lt;/span&gt; Page_PreInit(&lt;span class="kwd"&gt;object&lt;/span&gt; sender, EventArgs e)
&lt;strong id="11"&gt;11   &lt;/strong&gt;    {
&lt;strong id="12"&gt;12   &lt;/strong&gt;        Response.Write(&lt;span class="st"&gt;&amp;quot;HI&amp;quot;&lt;/span&gt;);
&lt;strong id="13"&gt;13   &lt;/strong&gt;        Page.Theme = Profile.MyTheme;
&lt;strong id="14"&gt;14   &lt;/strong&gt;    }
&lt;strong id="15"&gt;15   &lt;/strong&gt;}
&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;If Masterpages do&amp;nbsp;not have the preinit event, then how can I set the theme dynamically for all my pages that are based upon the single&amp;nbsp;Masterpage?&lt;/p&gt;&lt;p&gt;Thank you for any help.&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>