howto handel a couple of asp.net pages with nearly the same code?
hi i have a problem, i'm working on a aps.net page which have a couple of sites开发者_高级运维. the sites are nearly eqal but have e.g. a other count of labels the but the method names are the same.
what would be the best design strategy to keep all this sites easy to handle?
Derive a base class from System.Web.UI.Page
, and inherit from this for your specific pages.
public class MyApplicationBasePage : System.Web.UI.Page
{
// common methods/fields here
}
public partial class SpecificPage_1 : MyApplicationBasePage { }
public partial class SpecificPage_2 : MyApplicationBasePage { }
...etc
Have a look at this article for example.
Use WebParts. Dont repeat the code if its same thing in several views. Just compose it of several elementary partial views.
精彩评论