Version 1.3 and Class Page

Topics: ASP.NET 2.0, Business Logic Layer
Jan 30, 2008 at 5:36 PM
In previous version of BE.NET the class Page in namespace BlogEngine.Core was declared as partial... and extend this class to add some other attributes and I keep the code in separated file but declared as partial class Page, just extending the class.
Now the class Page cames sealed, and my extention don't work.. of course I change this definition in the source code, recompile again and everything is working fine...
But I want to know the pourpose of seald the Page class and if there is other way to implement extentions of this class for custom attributes kepping maximun compatibility with future bE.Net releases.
Thanks.
Jan 31, 2008 at 12:06 AM
The only purpose of the partial keyword is to split a large class into seperate logical files (where it makes sense to do so of course), not really to extend the class.

I can kind of see why you might have done this as keeping your changes in a seperate file makes it easier to manage as the core BE.Net files get updated in new releases. It's not really a good way to go though.

There are many official mechanisms built into BE.Net (Extensions, Widgets, User Controls etc.) which allow you to supplement and extend the system with your own code in a managed reliable way.

If it's at all possible, my advice would be to use one of the above to accomplish what you are trying to do.
Jan 31, 2008 at 12:06 AM
Edited Jan 31, 2008 at 12:10 AM
Remember that in a user control you can use this.Page to get a reference to the page that the user control is on.

If you are only using public methods and properties of the page class in your custom methods, you can easily access these from the control and pass them into the methods on a custom class.
Jan 31, 2008 at 1:11 AM
My objetive is extend fields of the object BlogEngine.Core.Page, and not the System....UI.Page.
I'm implementing new properties and methods to read/write the new XML nodes in pages files... I also made some changes in admin/Pages/Pages.aspx, in order to show the controls to edit my new Pages's attributes.
Also, I create a new Provider inheriting from XmlBlogProvider in order to manage my new Page object and overriding the SelectPage and InsertPage... here is when I read/write new XML nodes based in new Page's properties.
Bassically, I want to save more information in the XML file of each page and edit this information in the admin page,a nd of course this new information should have in the same Object as others ..
so any advice to keep the right way will be appretiated.
Thanks a lot.