<?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: Removing master page at runtime</title><link>http://forums.asp.net/thread/3484015.aspx</link><pubDate>Thu, 29 Oct 2009 16:03:19 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3484015</guid><dc:creator>cevah</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3484015.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=139&amp;PostID=3484015</wfw:commentRss><description>&lt;p&gt;Thanks a lot for your reply guys!&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Removing master page at runtime</title><link>http://forums.asp.net/thread/1959557.aspx</link><pubDate>Wed, 17 Oct 2007 03:08:46 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1959557</guid><dc:creator>Amanda Wang - MSFT</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1959557.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=139&amp;PostID=1959557</wfw:commentRss><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Base on your description, you want the content page to remove the master page at runtime,that is to&amp;nbsp;as say, do not use the master page at runtime, right?&lt;/p&gt;
&lt;p&gt;But if the content page used the master page, the aspx file will like this:&lt;/p&gt;
&lt;p&gt;&lt;span class="dir"&gt;&amp;lt;%@ Page Language=&amp;quot;C#&amp;quot; MasterPageFile=&amp;quot;~/TestCases/DEFAULT.master&amp;quot; AutoEventWireup=&amp;quot;true&amp;quot; CodeFile=&amp;quot;Default.aspx.cs&amp;quot; Inherits=&amp;quot;TestCases_Default&amp;quot; Title=&amp;quot;Untitled Page&amp;quot; %&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;lt;&lt;span class="tag"&gt;asp:Content&lt;/span&gt;&lt;span class="attr"&gt; ID=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;Content1&amp;quot;&lt;/span&gt;&lt;span class="attr"&gt; ContentPlaceHolderID=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;Main&amp;quot;&lt;/span&gt;&lt;span class="attr"&gt; Runat=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;Server&amp;quot;&lt;/span&gt;&amp;gt;&lt;br /&gt;&amp;lt;/&lt;span class="tag"&gt;asp:Content&lt;/span&gt;&amp;gt; 
&lt;p&gt;So it is very different with the normall page, so the content page only can work fine with the master page, or else it will throw the error message. 
&lt;p&gt;About how the master page and the content page work, you can read this article: &lt;a href="http://www.odetocode.com/Articles/450.aspx"&gt;http://www.odetocode.com/Articles/450.aspx&lt;/a&gt; 
&lt;p&gt;But you can try to implement it by using the&amp;nbsp;&lt;span class="djen"&gt;&lt;span&gt;flexible&amp;nbsp;method.&lt;/span&gt;&lt;/span&gt; 
&lt;p&gt;&lt;span class="djen"&gt;&lt;span&gt;For exampe:&lt;/span&gt;&lt;/span&gt; 
&lt;p&gt;&lt;span class="djen"&gt;&lt;span&gt;You can create a empty master page, there is nothing other than the contentplaceholder control and the html tags. So if the content page use this master page, &lt;font face="Times New Roman" size="3"&gt;the page only display itself. &lt;/font&gt;&amp;nbsp;At the runtime. change the content page&amp;#39;s masterpagefile in the PreInit event programmatically.&lt;/span&gt;&lt;/span&gt; 
&lt;p&gt;If you do like this, will not disturb the other existed pages&lt;font face="Times New Roman" size="3"&gt;.&lt;/font&gt; 
&lt;p&gt;&lt;span class="djen"&gt;&lt;span&gt;for example:&lt;/span&gt;&lt;/span&gt; 
&lt;p&gt;&lt;span class="djen"&gt;&lt;span&gt;1. the empty master page:&lt;/span&gt;&lt;/span&gt; &lt;/p&gt;&lt;span class="djen"&gt;&lt;span&gt;&lt;span class="dir"&gt;&amp;lt;%@ Master Language=&amp;quot;C#&amp;quot; AutoEventWireup=&amp;quot;true&amp;quot; CodeFile=&amp;quot;MasterPage.master.cs&amp;quot; Inherits=&amp;quot;TestCases_MasterPage&amp;quot; %&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;&lt;span class="tag"&gt;!DOCTYPE&lt;/span&gt; html PUBLIC &amp;quot;-//W3C//DTD XHTML 1.0 Transitional//EN&amp;quot; &amp;quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&amp;quot;&amp;gt; &amp;lt;&lt;span class="tag"&gt;html&lt;/span&gt;&lt;span class="attr"&gt; xmlns=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;http://www.w3.org/1999/xhtml&amp;quot;&lt;/span&gt; &amp;gt;&lt;br /&gt;&amp;lt;&lt;span class="tag"&gt;head&lt;/span&gt;&lt;span class="attr"&gt; runat=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;server&amp;quot;&lt;/span&gt;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;span class="tag"&gt;title&lt;/span&gt;&amp;gt;Untitled Page&amp;lt;/&lt;span class="tag"&gt;title&lt;/span&gt;&amp;gt;&lt;br /&gt;&amp;lt;/&lt;span class="tag"&gt;head&lt;/span&gt;&amp;gt;&lt;br /&gt;&amp;lt;&lt;span class="tag"&gt;body&lt;/span&gt;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;span class="tag"&gt;form&lt;/span&gt;&lt;span class="attr"&gt; id=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;form1&amp;quot;&lt;/span&gt;&lt;span class="attr"&gt; runat=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;server&amp;quot;&lt;/span&gt;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;span class="tag"&gt;div&lt;/span&gt;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;span class="tag"&gt;asp:contentplaceholder&lt;/span&gt;&lt;span class="attr"&gt; id=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;ContentPlaceHolder1&amp;quot;&lt;/span&gt;&lt;span class="attr"&gt; runat=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;server&amp;quot;&lt;/span&gt;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;span class="tag"&gt;asp:contentplaceholder&lt;/span&gt;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;span class="tag"&gt;div&lt;/span&gt;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;span class="tag"&gt;form&lt;/span&gt;&amp;gt;&lt;br /&gt;&amp;lt;/&lt;span class="tag"&gt;body&lt;/span&gt;&amp;gt;&lt;br /&gt;&amp;lt;/&lt;span class="tag"&gt;html&lt;/span&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="djen"&gt;&lt;span&gt;
&lt;p&gt;&amp;nbsp;2. Set the content page&amp;#39;s masterpagefile &amp;nbsp;programatically&lt;/p&gt;
&lt;p&gt;&lt;span style="COLOR:blue;"&gt;void&lt;/span&gt;&lt;span style="COLOR:black;"&gt; BasePage_PreInit(&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;object&lt;/span&gt;&lt;span style="COLOR:black;"&gt; sender, &lt;/span&gt;&lt;span style="COLOR:teal;"&gt;EventArgs&lt;/span&gt;&lt;span style="COLOR:black;"&gt; e)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MasterPageFile = &lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;&amp;quot;~/&lt;font color="#000000"&gt;MasterPage&lt;/font&gt;.master&amp;quot;&lt;/span&gt;&lt;span style="COLOR:black;"&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="COLOR:black;"&gt;Hope it helps.&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;</description></item><item><title>Re: Removing master page at runtime</title><link>http://forums.asp.net/thread/1956411.aspx</link><pubDate>Mon, 15 Oct 2007 13:38:00 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1956411</guid><dc:creator>sbadriprasad</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1956411.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=139&amp;PostID=1956411</wfw:commentRss><description>&lt;p&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="/Themes/fan/images/icon-quote.gif"&gt; &lt;strong&gt;ca8msm:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt; 
&lt;p&gt;It&amp;#39;s probably easier to create a second blank Master Page so you can set it to use that rather than trying to remove all references to a Master Page. You can then set it like this:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;pre class="coloredcode"&gt;    &lt;span class="kwd"&gt;Protected Sub&lt;/span&gt; Page_PreInit(&lt;span class="kwd"&gt;ByVal&lt;/span&gt; sender &lt;span class="kwd"&gt;As Object&lt;/span&gt;, &lt;span class="kwd"&gt;ByVal&lt;/span&gt; e &lt;span class="kwd"&gt;As&lt;/span&gt; System.EventArgs) &lt;span class="kwd"&gt;Handles Me&lt;/span&gt;.PreInit
        Page.MasterPageFile = &lt;span class="st"&gt;&amp;quot;othermasterpage.master&amp;quot;&lt;/span&gt;
    &lt;span class="kwd"&gt;End Sub&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/p&gt;
&lt;p&gt;if my page1.aspx had materpage1. master and i am calling this page1.aspx from page2.aspx, then where should i use your code? to change the blankmaster.master. since i said i dont want to touch the old page that is page1.aspx in this example how to chage the master page of page1 from page2.&lt;/p&gt;
&lt;p&gt;Edited: can you please explain in C#.&lt;/p&gt;</description></item><item><title>Re: Removing master page at runtime</title><link>http://forums.asp.net/thread/1956346.aspx</link><pubDate>Mon, 15 Oct 2007 13:09:06 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1956346</guid><dc:creator>ca8msm</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1956346.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=139&amp;PostID=1956346</wfw:commentRss><description>&lt;p&gt;It&amp;#39;s probably easier to create a second blank Master Page so you can set it to use that rather than trying to remove all references to a Master Page. You can then set it like this:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;pre class="coloredcode"&gt;    &lt;span class="kwd"&gt;Protected Sub&lt;/span&gt; Page_PreInit(&lt;span class="kwd"&gt;ByVal&lt;/span&gt; sender &lt;span class="kwd"&gt;As Object&lt;/span&gt;, &lt;span class="kwd"&gt;ByVal&lt;/span&gt; e &lt;span class="kwd"&gt;As&lt;/span&gt; System.EventArgs) &lt;span class="kwd"&gt;Handles Me&lt;/span&gt;.PreInit
        Page.MasterPageFile = &lt;span class="st"&gt;&amp;quot;othermasterpage.master&amp;quot;&lt;/span&gt;
    &lt;span class="kwd"&gt;End Sub&lt;/span&gt;&lt;/pre&gt;&amp;nbsp;&amp;nbsp;</description></item><item><title>Removing master page at runtime</title><link>http://forums.asp.net/thread/1956201.aspx</link><pubDate>Mon, 15 Oct 2007 11:59:33 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1956201</guid><dc:creator>sbadriprasad</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1956201.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=139&amp;PostID=1956201</wfw:commentRss><description>&lt;font size="3"&gt;&lt;font face="Times New Roman"&gt;Hi,&lt;/font&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;font face="Times New Roman"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I have a page with master page developed earlier and it is working fine. Now I want the same page to be used in some other module where I don’t want the master page, only the page has to be displayed. I don’t want the code to be repeated here by creating a new page and copying the old code, instead I want to call the page and the master page has to be removed runtime.&lt;/font&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;font face="Times New Roman"&gt;Note: I don’t want to disturb the existing page. So no code change in the existing page. &lt;/font&gt;&lt;/font&gt;
&lt;p&gt;&lt;font face="Times New Roman" size="3"&gt;Has anyone faced this kind of situation? Any help on this will be highly appreciated.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>