Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 92787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:14:32+00:00 2026-05-10T23:14:32+00:00

I’m developing a new ASP .NET website which is effectively a subset of the

  • 0

I’m developing a new ASP .NET website which is effectively a subset of the pages in another site we’ve just released. Two or three of the pages will need minor tweaks but nothing significant.

The obvious answer is to simply copy all of the code and markup files into the new project, make the aforementioned tweaks, and consider the job done. However I’m not keen on this at all due to the amount of duplicated code it will create.

My next idea was to move the code for the pages (i.e. the code-behind file) into a separate assembly which can then be referenced from both sites. This is a little awkward however as if you don’t take the designer file with it, you get a lot of build errors relating to missing controls. I don’t think moving the designer file is a good idea though as this will need to be regenerated each time the markup is altered.

Does anyone have any suggestions for a clean solution to this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T23:14:32+00:00Added an answer on May 10, 2026 at 11:14 pm

    You might want to take a look at the MVP pattern. Since you are probably using WebForms it would be hard to migrate to ASP.Net MVC, but you could implement MVP pretty easily into existing apps.

    On a basic level you would move all the business logic into a Presenter class that has a View that represents some sort of interface:

    public class SomePresenter {     public ISomeView View{get; set;}      public void InitializeView()     {         //Setup all the stuff on the view the first time          View.Name = //Load from database         View.Orders = //Load from database     }      public void LoadView()     {         //Handle all the stuff that happens each time the view loads     }      public Int32 AddOrder(Order newOrder)     {         //Code to update orders and then update the view     } } 

    You would define your interface to hold the atomic types you want to display:

    public interface ISomeView {     String Name {get; set;}     IList<Order> Orders{get; set;} } 

    Once those are defined you can now simply implement the interface in your form:

    public partial class SomeConcreteView : System.Web.UI.Page, ISomeView {     public SomePresenter Presenter{get; set;}      public SomeConcreteView()     {         Presenter = new SomePresenter();          //Use the current page as the view instance         Presenter.View = this;      }      protected void Page_Load(object sender, EventArgs e)     {         if(!IsPostBack)         {             Presenter.InitializeView();              }          Presenter.LoadView();     }      //Implement your members to bind to actual UI elements     public String Name     {         get{ return lblName.Text; }         set{ lblName.Text = value; }     }      public IList<Order> Orders     {         get{ return (IList<Order>)ordersGrid.DataSource; }         set         {             ordersGrid.DataSource = value;             ordersGrid.DataBind();         }     }      //Respond to UI events and forward them to the presenter     protected virtual void addOrderButton_OnClick(object sender, EventArgs e)     {         Order newOrder = //Get order from UI         Presenter.AddOrder(newOrder);     } } 

    As you can see, your code behind is now extremely simple so code duplication is not a big deal. Since the core business logic is all wrapped up in a DLL somewhere, you don’t have to worry about functionality getting out of sync. Presenters can be used in multiple views, so you have high reuse, and you are free to change the UI without affecting the business logic as long as you adhere to the contract.

    This same pattern can apply to user controls as well, so you can get as modular as you need to. This pattern also opens up the possibility for you to unit test your logic without having to run a browser 🙂

    The patterns and practices group has a nice implementation of this: WCSF

    However, you don’t have to use their framework to implement this pattern. I know this may look a little daunting at first, but it will solve many of the problems (In my opinion) you are running into.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 98k
  • Answers 98k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Contact facebook and state your problem, they might relax the… May 11, 2026 at 7:39 pm
  • Editorial Team
    Editorial Team added an answer There are about 3 different frameworks, PhoneGap, QuickConnect, and Rhomobile.… May 11, 2026 at 7:39 pm
  • Editorial Team
    Editorial Team added an answer git log FETCH_HEAD~12..FETCH_HEAD this will show the latest 12 commits… May 11, 2026 at 7:39 pm

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.