PageBaseType

pageBaseType is an extremely powerful setting that you might to use when all your application pages inherit from a common class. it is in the section of the web.config.
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
Print | posted on Sunday, July 23, 2006 11:08 AM

Feedback

# re: PageBaseType

left by Ravi at 6/11/2007 11:20 PM Gravatar
Hi,
Can you share a real life example.

Thanks
Ravi

# re: PageBaseType

left by Dheeman Dutta at 6/12/2007 6:04 PM Gravatar
Suppose you are trying to load a Masterpage explicitly using code based on some conditions , and this applies to all the pasge in your website. Using this contaring for loading master pages , you won't be able to specify the master page while adding any page in the website.

Suppose we have this class
>>>>>
public class DynamicMasterPage : System.Web.UI.Page
{
protected override void OnPreInit(EventArgs e)
{
// LoadMasterPage() loads a master page based on some criteria.
string masterFile = LoadMasterPage();
if (!masterFile.Equals(string.Empty))
{
base.MasterPageFile = masterFile;
}
base.OnPreInit(e);
}
}
>>>>>>

Now in order to make all pages in your website inherit from this class you need to mention the pageBaseType in the Web.Config.

>>>>

<system.web>
<pages pageBaseType="DynamicMasterPage" />
</system.web>

>>>>>


Cheers

# re: PageBaseType

left by Vladimir Kelman at 4/21/2008 6:57 AM Gravatar
Only works with inline ASPX pages, unfortunately. VS still generates code-behind pages inheriting System.Web.UI.Page, which overrides pageBaseType. So, it is pretty useless.

http://pro-thoughts.blogspot.com/

# re: PageBaseType

left by shingo yabuki at 12/30/2010 7:51 PM Gravatar
it's not useless actually, using .net 3.5 and above I made a common basepage and every page had to override a method I created, even though the page behind will inherit from system.web.ui.page on visual studio, the compiler will complain about the lack of implementation of the abstract methods forcing that page to change it's inheritance to the type defined on web.config

# re: PageBaseType

left by Sagar at 6/17/2011 4:39 PM Gravatar
inherits attribute from @Page directive overrides the pageBaseType value of web.config.
but I don't want to override it.How would I stop from overriding?
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: