I'm building a asp.net web site
i build a class localiziedpage that inherit from System.Web.UI.Page this class in dealing with all localization of the page. ii have a class basepage that inherit fro开发者_如何学Cm localiziedpage that get all simple data from db for a page (h1,title,main content,description...)now i need to create a page that bring another type of data (news list,albums ...) do i need to build a separate class for every type of page?
for rss page a rssPage class that inherit from basePage ?
for newslist page a newsListPage that inherit from basePage ?You generally only use a base page in ASP.NET webforms where you want to share common functionality across a number of pages. If every page on your site has to deal with localised information then it probably makes sense to use a base page here. However, things like news listings will only exist one a certain pages, so there is no reason to use a base class.
Instead you would build the actual functionality for these pages using classes in a class library that are then referenced from using statements in the page. So for a news listing page you might have classes that fetch data from the database, then a class that represents a single news item with methods that bring back collections of news items, say as a List<NewsItem>
.
In your page you might then have an ObjectDataSource
that is bound to your List<NewsItem>
and rendered via an asp:Repeater
control in your .aspx declarative code.
精彩评论