Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to inherit a page class from a class library
    text
    copied!<p>Ayup</p> <p>I might be asking a dumb question, but I have a client for whom I need to build many websites (10+) (asp.net 3.5) which will all the pages on each site will have the same codebehind, but the sites will launching in different regions and whilst following the same template, will have different content.</p> <p>I have built and launched site 1, and sites 2, 3 &amp; 4 is nearly live, but it occurs to me that as all the sites are basically the same, the code is going to get more complicated to update as it will be duplicated, so if I need to do a bug fix on one site, I'll need to do the fix on all websites (and this is going to get complicated.)</p> <p>I was wondering if it possible to somehow create a class library of all the current aspx.cs files, reference this dll in each website and then inherit these classes into the .aspx.cs files. So default.aspx in each site would still have a CodeFile of "Default.aspx.cs", but Default.aspx.cs would inherit the corresponing class from the dll:</p> <pre><code>using WebPagesClass; public partial class _Default : WebPagesClass._Default { } </code></pre> <p>The reason for doing it like this is that if I need to change any code on a specific website (for minor changes in languages for instance), I can override the page functions and change the parts required. For all other pages which have not cha, I can just copy from a single website.</p> <p>Is this vaguely possible? If not anyone one got any killer suggestions of how to manage so many websites from a single codebase?</p> <p>Cheers T</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload