Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / June 2006

Tip: Looking for answers? Try searching our database.

ASP.Net inheritance (different view (page) per URL)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mr Flibble - 22 Jun 2006 10:15 GMT
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 :-)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.