CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

ASP.NET Web Hosting – 3 Months Free!



Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 7/20/2007 4:32:56 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 4 Views: 54 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
5 Items, 1 Pages 1 |< << Go >> >|
BSinatra
Asp.Net User
Error changing the master page specified on content page7/20/2007 4:32:56 PM

0/0

I am attempting to make a website that can be edited online by the owner.  One of the settings is layout and I want to do this through masterpages.  The result of their choice is stored in an xml file called layout.xml.

I added this bit of code to the content page:


 

public class DynamicPage : System.Web.UI.Page
{
protected override void OnPreInit(EventArgs e)
{
SiteTools st = new SiteTools();
string layout = st.getLayout(Request);
if (!layout.Equals(string.Empty))
{
base.MasterPageFile = layout;
}
base.OnPreInit(e);
}
}

here is the getLayout portion

 

public string getLayout(HttpRequest Request)
{
getPath(Request);
try { xdoc.Load(_path + "\\config.xml");
XmlNodeList layout = xdoc.GetElementsByTagName("layout");

if (layout.Count > 0)
{

return layout[0].ChildNodes[0].InnerText;
}
return "";
}
catch (Exception ex)
{
if (ex.Message.Contains("Could not find a part of the path"))
{

return "XmlCreated";
}
return "Error: " + ex.Message;


}
}

  here is the layout content of config.xml

<theme><![CDATA[coffee]]></theme>
 <layout><![CDATA[~/masterpageb.master]]></layout>

when I try to access the edited page I get this error:

Content controls are allowed only in content page that references a master page.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Content controls are allowed only in content page that references a master page.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[HttpException (0x80004005): Content controls are allowed only in content page that references a master page.]
System.Web.UI.MasterPage.CreateMaster(TemplateControl owner, HttpContext context, VirtualPath masterPageFile, IDictionary contentTemplateCollection) +1116
System.Web.UI.Page.get_Master() +49
System.Web.UI.Page.ApplyMasterPage() +17
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1368
 

 

 

Any ideas? 

Thanks,

Bob 

 


 

 

 

Benners_J
Asp.Net User
Re: Error changing the master page specified on content page7/20/2007 5:19:37 PM

0/0

The error you are getting indicates that a master page is not set.  My guess is that the call to getLayout is returning an empty string, and you don't have a default masterpage set in your page directive.  Can you try the getLayout method or run through it with the debugger to see what it is returning?

BSinatra
Asp.Net User
Re: Error changing the master page specified on content page7/20/2007 5:23:44 PM

0/0

 where would I set the page directive?  This is probably my problem.....

Benners_J
Asp.Net User
Re: Error changing the master page specified on content page7/20/2007 5:36:25 PM

0/0

The first line of your ASPX page is the page directive.  It begins with <%@ Page

Inside that tag, add: MasterPageFile="~/Default.master"  (Change the ~/Default.Master to the location of your default page.)

This will set a default master page that will be used if your call to getLayout comes back blank.

BSinatra
Asp.Net User
Re: Error changing the master page specified on content page7/20/2007 6:31:15 PM

0/0

Okay, I had originally taken that line out. Thinking that it needed to be blank to be set by program... 

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


Free Download:

Books:
Pro ASP.NET 2.0 in C# 2005 Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1255, Published: 2005
Pro ASP.NET 2.0 in VB 2005: From Professional to Expert Authors: Laurence Moroney, Matthew MacDonald, Pages: 1253, Published: 2006
Pro ASP.NET 2.0 in C# 2005: Create Next-generation Web Applications with the Latest Version of Microsoft's Revolutionary Technology Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1426, Published: 2006
Pro ASP.NET 2.0 Website Programming Authors: Damon Armstrong, Pages: 641, Published: 2005
Using Lotus Manuscript: The Progressional's Guide to Sophisticated Document Processing on the IBM PC Authors: Kay Yarborough Nelson, William Fletcher, Pages: 410, Published: 1987

Web:
Error changing the master page specified on content page - ASP.NET ... Error changing the master page specified on content page. Last post 07-20-2007 2 :31 PM by BSinatra. 4 replies. Sort Posts: ...
Customizing Master Pages in Windows SharePoint Services Alternatively, you can change the master page used by a content page by directly changing the URL for the MasterPageFile attribute specified in the page ...
ASP.Net 2.0 - Master Pages: Tips, Tricks, and Traps Apr 11, 2006 ... If we try to open a content page in design view and the content page uses a nested master page design, the designer will display an error ...
Change the current master page - SharePoint Designer - Microsoft ... In the Master Page error box, click change the mapping of the content regions. ... The Current Page column displays the content regions specified by the ...
CodeProject: An Extensible Master-Page Framework for ASP.NET 1.1 ... Now, our model would have a Master Page that in turn is composed of Master ..... The content needs to be appearing in a specified area within the ...
Specifying the Master Page Programmatically : The Official ... Because a content page's master page can be set programmatically at runtime .... referenced the Site.master file. But now the page renders without error. ...
CodeGuru: An In-Depth Coverage of ASP.NET 2.0's Master Pages: Part ... Feb 1, 2006 ... Note: If you have specified the master page file to use in the web.config file ... at runtime you will get an InvalidCastException error. ...
Heather Solomon - MVP, WSS - SharePoint Branding and Design SharePoint 2007 Design Tip: Changing the Flyout Menu Arrow Hover Color ... Master Page Error from Exporting file from SharePoint Designer ...
Microsoft Enterprise Content Management (ECM) Team Blog : Building ... Because this is specified in the Master Page, the change is seen on ... we have specified the “site” site images library in SPURL, changing the company logo ...
Master Pages, Themes, and Control Skins NET throws an error when you access the. page and informs you that Content controls can only be used in conjunction with a Master. Page. ...




Search This Site:










accessing master pages from base page class

menu item without explicit url (assuming default.aspx page) does not get selected property

space between 2 table rows

hi my website using masterpage but it very slow in open

auto-binding treeview

treeview - find nodes and remember selection

sending back values to opener pages with master pages

problem in treeview

calling a class with master pages

textbox control in master & content pages

treeview not binding

sitemap web editor

master with updatepanel + content with fileupload

menu control - passing parameter into javascript function

how to apply theme to masterpages

uncooperatve content place holder

how can i bind a xml column in sql 2005 to a treeview control

dynamically invoke different themes in master page

skin detailsview templatefield

problem related to menu navigation

content place holder

treeview: displaying the expand/collapse buttons on right side of text instead of left

avoir child nesting in masterpage

ff and ie incompatibility

completely dynamic sitemap

tabstrip problem

need help with textbox

existence of skins

using dynamicitemformatstring to add custom icons to the system.web.ui.webcontrols.menu - possible?

how to format menu as a tabstrip with submenu as a second bar of links

  Privacy | Contact Us
All Times Are GMT