Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subclass Page that has MasterPage 1

Status
Not open for further replies.

BillKuhn

Programmer
Jun 1, 2007
21
US
(be kind - I'm still pretty new to .NET)

I'm attempting to set up a useful base web page for a project.

I've figured out how to subclass a page, but I'd like that subclassed page to have a masterpage assigned (and possibly some other properties as well).

If I try to set the masterpage in the subclassed page's OnPreInit event, I still wind up with the 'Content controls have to be top-level controls in a content page or a nested master page ..' error.

Is what I am trying to do possible? It seems awfully primitive to have to reassign master pages to each new page I create for my site..

I'm doing this in vb.net in VS2005 BTW.


Bill Kuhn - MCSE
bkuhn@kuhngroup.com
The Kuhn Group, Inc.
 
master pages are a special case. the compiled code treats them like a WebUserControl (ascx) rather than a WebForm (aspx) property.

You could try setting the Master page in the OnInit event rathter than the OnPreInit.

You can also set the MasterPage in the web.config file. then you don't need to worry about setting this up for each page.

<Configuation>
<system.web>
<pages masterPageFile="MyMaster.Master" />
</system.web>
</Configuation>


Jason Meckley
Programmer
Specialty Bakers, Inc.
 
I didn't know you could set a global masterpage in the web.config - that makes it too easy!

Thanks!



Bill Kuhn - MCSE
bkuhn@kuhngroup.com
The Kuhn Group, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top