Geeks With Blogs
Dheeman Dutta Just Another Blog.....
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. Posted on Sunday, July 23, 2006 11:08 AM | Back to top


Comments on this post: PageBaseType

# re: PageBaseType
Requesting Gravatar...
Hi,
Can you share a real life example.

Thanks
Ravi
Left by Ravi on Jun 11, 2007 11:20 PM

# re: PageBaseType
Requesting 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
Left by Dheeman Dutta on Jun 12, 2007 6:04 PM

# re: PageBaseType
Requesting 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/
Left by Vladimir Kelman on Apr 21, 2008 6:57 AM

# re: PageBaseType
Requesting 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
Left by shingo yabuki on Dec 30, 2010 7:51 PM

# re: PageBaseType
Requesting 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?
Left by Sagar on Jun 17, 2011 4:39 PM

Your comment:
 (will show your gravatar)


Copyright © Dheeman Dutta | Powered by: GeeksWithBlogs.net