MasterPage in Class library

  • Thread starter Thread starter Joey
  • Start date Start date
J

Joey

Hi,

is it possible to move a MasterPage into a class library so that it can be
used by multiple websites?

if not, is there an alternative way?

reagrds,
 
Any particular reason you cannot simply move the .master file around?
Consolidate all your server-side code (cs or vb) into the actual .master
file just as you could any .aspx file and move it around.

I think your only other option would be creating a class that inherits from
System.Web.UI.MasterPage and overriding the correct events to render out the
proper HTML, then include the proper ContentPlaceHolders into the control
tree. All of this might be a bit of a pain. I don't see why it wouldn't
work, though; on the other hand I'm not sure how kindly Visual Studio's
design-time facilities for master-page development would take to all
this....dunno...never tried....
 
Any particular reason you cannot simply move the .master file around?
Consolidate all your server-side code (cs or vb) into the actual .master
file just as you could any .aspx file and move it around.

I think your only other option would be creating a class that inherits
from System.Web.UI.MasterPage and overriding the correct events to render
out the proper HTML, then include the proper ContentPlaceHolders into the
control tree. All of this might be a bit of a pain. I don't see why it
wouldn't work, though; on the other hand I'm not sure how kindly Visual
Studio's design-time facilities for master-page development would take to
all this....dunno...never tried....

Generally, I use Visual SourceSafe for this sort of re-use... Just create
the MasterPage (and its associated code-behind file) once and then, in VSS,
share it into all the other projects which need it... Then, any time you
change it in one project, it will automatically update it in all the
others...
 
Back
Top