Hi,
I have a newbie question for
(ASP.Net 2.0 framework) which is based on Design Pattern / Coding Trick
--> I need to :-
- Inherit one aspx page and its code (super abstract class) that in turn inherits System.Web.UI.P age
such that this page servers a base model for other aspx pages
--> Constraints
-- Want only Aspx page and not Code Page (like Base Class) !!!
Reason :- since the above abstract page is having user controls and points to the master page.
-- No Interface !!!
I dont want to implement this page as an Interface since there are some methods that will have the same code when overridden by the classes / aspx pages that may be implementing it causing duplicate code
So, an Abstract class model with abstract methods looks favorable
-- .Net only permits for single-level inheritance model
--> Some of the ways that I looked into are
-> Defining a Master Page ... but not sure about master page inheritence and this approach is not I like to have
-> Having a User Control .... which will have embedded user controls and loss of page theming ...
-> Thinking of having a base class ... which will define the aspx and html controls in the code .. not sure about this approach
--> Is there any better way of preserving the theme as well as achive some sort of multiple or 2 level inheritance with a better approach in ASP.Net 2.0 ?
(please correct me if I am missing something / Wrong)
7 4095
This is actually incorrect:
"-- .Net only permits for single-level inheritance model "
Your inheritance hierarchy can be as deep as you want, i.e., base < derived1 < derived2 < derived3
I think what you are getting at is that .Net only supports single inheritance, which means that a class can only inherit directly from one other class. i.e, you can't do base1, base2 < derived1
I think you're better off going with master page and user controls, though -- that's the way most people do it.
Frinavale 9,735
Recognized Expert Moderator Expert
VB.NET only allows you to inherit from one class; however, the class you inherit from can inherit from another class. C# allows you to inherit from more than one class.
You should really look into using a MasterPage.
A MasterPage is compiled with your ASPX Content Pages to provide a template that all pages use.
You can use UserControls as well if you'd like.....
You haven't really explained what you are trying to do.
Are you creating several pages in your site, and you'd like to have the same layout for all pages? Use a MasterPage to do this...also use a global external style sheet (CSS) to help you design your site's look and feel.
Are you creating one page that has several different components?
Use Web User Controls so that you can easily display more than one component on a page at a time.... If you are using a component in several different pages you should put it into a Web User Control so that it simplifies implementing and maintaining the component.
thanks podster and frinavale ...
--------------------------------------------------------------------------------------------- @Frinavale
---------------------------------------------------------------------------------------------
-> actually, i m trying to achieve a combination of both !!!
I am trying to create a Template - kind of page that uses
a) Already has all the Css (via one Master Page) and
b) links to combination of various User Controls
So that ... if I want to create other pages with the same model, I have to just inherit this page and pass different parameters from the subclass to get different types of say results like Custom-made Reports!!!
On One thought, I was thinking of having a aspx page very parallel to Base Pages . cs / .vb with all the above embedded in it and then try to inherit this page in the subclasses (.aspx and Code behind files) ... but am not sure how to go about this at this point
Frinavale 9,735
Recognized Expert Moderator Expert
Why do you need to inherit anything?
I do not see any reason why you want to inherit anything when you have MasterPages, UserControls and CSS at your disposal.
If you want to create any new pages using that mode, create a new Content Page that uses the MasterPage you've developed.....
You don't have to inherit anything.
Your pages should use instances of your UserControls where needed.
There's no reason why you want to have a UserControl in a base class if it isn't going to be used.
Hi Frinavale,
I wanted to inherit since I have lots of pages that have some commonality which is the same master page and same sets of user controls ....
the only thing varies is the parameters ; Considering Refactoring of the Code ... I wanted to create a - sort - of - <GOD> ASPX page that has Master page and the user controls and the variables ....
and most of the other pages will then call this page with the paramter they want so the code is drastically reduced in these child custom ASPX pages ... they just need to supply the right list of parameters ...
Frinavale 9,735
Recognized Expert Moderator Expert
I tend to use the K.I.S.S. (Keep It Small And Simple) approach when developing any application. Implementing a "God" Page is basically the opposite to that approach.
When you have such a massive class as the Base class you are going to have a hard time maintaining that class and the rest of them.
As soon as you need to add another parameter in the Base Class you're going to have to modify every other page just because one page requires it.
I would strongly recommend against this style, but to-each-their-own. If you're dead set on doing this, then the best of luck to you :)
If I were you, I'd put the common functionality that exists on every page in the master page and create User Controls for features that aren't required on every page but are used in more than one. I'd add user controls the pages that require them. Each page would remain it's own page and there would be no "God" page.
If there are functions that are required on more than one page that do the same thing, I tend to add them to a class (not a page) I call "Utils". This class is "NotInheritable "/"Sealed" and only contains Public Static/Shared functions so that I can easily call the functions throughout my code and pages.
-Frinny
hmm..
you should use Master Pages..
Creating a GOD page and inheriting from it
is similar to creating Master page!!
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Santa |
last post by:
I am using Fritz Onion's "Asynchronous Pages" approach as mentioned in
the article http://msdn.microsoft.com/msdnmag/issues/03/06/Threading/default.aspx
to increase the performance of my ASPX page.I am using the Custom
thread pool as given in the article's sample.
Implementation:
===============
In AsyncPage.aspx I inhereted AsyncPage class instead of
System.Web.UI.Page.
SyncPage.aspx is like any other Web page which inherits
|
by: John Lau |
last post by:
Hi,
I am looking at the MS KB Article 306355: HOW TO: Create Custom Error
Reporting Pages in ASP.NET by Using Visual C# .NET
This article describes how to redirect errors to a custom html error page.
All six steps in the article work just fine. Then at the end of the
article, there is a little comment about redirecting errors to an aspx page
(instead of an html page):
|
by: Santa |
last post by:
I am using Fritz Onion's "Asynchronous Pages" approach as mentioned in
the article http://msdn.microsoft.com/msdnmag/issues/03/06/Threading/default.aspx
to increase the performance of my ASPX page.I am using the Custom
thread pool as given in the article's sample.
Implementation:
===============
In AsyncPage.aspx I inhereted AsyncPage class instead of
System.Web.UI.Page.
SyncPage.aspx is like any other Web page which inherits
|
by: tma |
last post by:
I have the following HTML in use on my web page. I need it to show a graphic
image on the page but do not know what to use in the codebehind to make the
graphic appear. If I load the source url in a browser by itself, the graphic
appears, but when I use the tag in a web page it does not. Anyone have a
suggestion for VB?
<img
src='http://www.domain.com/MohawkWS/MohawkHitCounter.aspx?ItemID=7103830413'
border=0 alt>
|
by: WJ |
last post by:
I have three ASPX pages:
1. "WebForm1.aspx" is interactive, responsible for calling a web site
(https://www.payMe.com) with $$$. It is working fine.
2. "WebForm2.aspx" is non-interactive, a listener in my site to capture a
"STATUS_CD" returned by www.payMe.com. It is working fine.
3. "WebForm3.aspx" is interactive page, responsibe to display the STATUS
CODE "POSTED" by "WebForm2.aspx".
4. My goal is to use "WebForm2.aspx" to call...
| |
by: ptass |
last post by:
Hi
In asp.net 2.0 an aspx files .cs file is a partial class and all works fine,
however,
I thought I’d be able to create another class file, call it a partial class
and have
that compile and load as a 3rd partial class. This would be handy so i can
generate
standard code into one of the partial classes, while having my custom code
untouched
|
by: John Rivers |
last post by:
ASPX which means ASPX pages, the code-behind concept, User Controls,
Web Controls etc. is very poorly designed and makes it extremely hard
to develop professional quality web applications.
ASPX is Microsoft's attempt to "dumb down" web application development
to help unskilled developers such as web design agencies achieve some
results.
For high quality applications IHttpHandlers are the way to go.
|
by: Bob Jones |
last post by:
Here is my situation:
I have an aspx file stored in a resource file. All of the C# code is
written inline via <script runat="server"tags. Let's call this page
B. I also have page A that contains some javascript code that calls
window.open. I pass the resource url of page B to Page A's window.open
call. Page B is then loaded and executed but none of the server-side
code is rendered. If I view the source of the page, the code (and page...
|
by: =?Utf-8?B?QXJ1bmVzaCBNb2hhbg==?= |
last post by:
Hello All:
I have an ASPX A.ASPX where I am displaying realtime data using embedded
ASPX page B.ASPX. When I go to next page/previous page from A.ASPX page, I
am able to go to next/previous page but when I try to perform any action on
next/previous page, it gives me an internet explorer error. I have added a
function 'onunload' on clientside in A.ASPX. I never see that onunload
function is getting called when A.ASPX is switched to next...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |