If I have a base page Default.aspx (and Default.aspx.cs). Can I have via
ASP.Net inheritance another page derived from Default.aspx(and .cs) as
it's base class and then override the Stylesheet declaration (amongst
other things)??
I have two pages that are identical bar the Stylesheet and so far I have
to maintain two pages to achieve this. It would be nice to maintain
just ONE page but have its various styles displayed under different URLs.
It must be said that I could have just one page and have a url of the
type http://localhost/Default.aspx?style=1 but although I'm not sure how
to implement this, I don't think it will achieve my end-goal since I
want each style to have it's own URL because I'm going to be using Basic
Authentication to lock down the different views.
Can anyone help?
Flibble
clintonG - 22 Jun 2006 15:27 GMT
1.1 or 2.0?
<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/
> If I have a base page Default.aspx (and Default.aspx.cs). Can I have via
> ASP.Net inheritance another page derived from Default.aspx(and .cs) as
[quoted text clipped - 14 lines]
>
> Flibble
Mr Flibble - 22 Jun 2006 15:47 GMT
> 1.1 or 2.0?
2.0 :-)
clintonG - 22 Jun 2006 20:18 GMT
So why not just set the Theme or StyleSheetTheme in the @Page directive for
the page you want to appear differently?
If your not using a Theme or StyleSheetTheme you should look at the new 2.0
HtmlHead class that allows us to write into the head element noting we have
to mark the head runat="server" which breaks XHTML validation but so what?
// use google...
htmlhead site:msdn2.microsoft.com
Then you can simply use logic in the Page_Load event to determine which
stylesheet to load.
Now backtracking, if you are going to use Themes with MasterPages changing
the Theme dynamically requires doing so in Page_PreInit which the MasterPage
does not support. (OdeToCode.com has excellent articles about MasterPages).
When using Page_PreInit a base class that inherits from the Page class
becomes practical...
// a base class signature
public class MyBaseClass : System.Web.UI.Page
Note all other content pages must then inherit from your base class...
// content page signature
public class _Default.aspx : MyBaseClass
How's that?
<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/
>> 1.1 or 2.0?
>
> 2.0 :-)