Inheritance - Extend Whole Website In Asp?
Mar 10, 2011
I work in a web agency and thus we are plenty of websites from several customers. They're built upon a cms we made, so websites are quite identical for the 90% of code. However, remaining 10% struggles me and my team as it involves not only the presentation layer but behavioral logics too (ex: a website1 requires simply user/pass registration while website2 needs more data, facebook connector, etc. But this is a very easy example). Making ad hoc development for our customers is becoming painful as keep each version aligned is getting really hard for us What I really dream to have is an extendible website that works by itself, but in which I can override a part. This behavior should sound like "look for the specific part, if it doesn't exists get the base one". The parts could be a method, a class, a page, a control, a static file.
example:
Suppose I want website2 to have an own login component, let's so imagine that we have a situation like:
/website_base
|_ login.aspx
/website1
/website2
|_ login.aspx
So, if I ask for [URL] I'll get /website_base/login.aspx, but if I ask for [URL] I'll get /website2/login.aspx
View 3 Replies
Similar Messages:
Feb 1, 2011
what is best to use in CTP 5 for inheritence. Ive heard of 3 ways of doing it. (This is indirectly addressed to Serenarules )
Table per Hierarchy ?
Table per Type ?
or able per Concrete Type ?
For those who wondering what the hell is that.. refer to http://weblogs.asp.net/manavi/default.aspx which is a nice blog about inheritence and polymorphism in CTP 5.
View 5 Replies
Jul 16, 2010
All my controllers inherit from a BaseController that has an ActionFilter attribute:
[AnalyticsData]
public class BaseController : Controller {}
public class AccountController : BaseController {}
Some of my Actions in my controllers reuse the AnalyticsData ActionFilter:
public class AccountController : BaseController
{
[AnalyticsData(Page="AccountProfile")]
public ActionResult Profile()
{
// return View
}
}
I notice that the AnalyticsData ActionFilter only runs once. This is a good thing and I only want it to run once, but I'm wondering how that happens. If I set my breakpoint inside the OnActionExecuting:
public class AnalyticsAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
// break point set here
}
}
only gets hit once when AccountController serves it Profile view. How do ActionFilters and/or Attributes work that [AnalyticsData(Page="AccountProfile")] on the Action overrides/replaces [AnalyticsData] on BaseController?
View 1 Replies
Aug 15, 2010
When people talk about extending a control are they just talking about inheritance?
View 1 Replies
Feb 6, 2010
Can anybody tell me why multiple inheritance is not supported in C#?
View 9 Replies
Mar 1, 2010
I'm trying to figure out if its possible to have multiple inheritance in a view in ASP.Net MVC. Right now I'm trying to print out a list of entries from two different tables from my model in a single View. I have the following line at the top of my view:
Inherits="System.Web.Mvc.ViewPage<List<GEApproval.Models.CoursePrefix>>"
But I also want to include the table Course as follows:
Inherits="System.Web.Mvc.ViewPage<List<GEApproval.Models.Course>>"
I went ahead and created a composite class as follows:
namespace GEApproval.Models
{
public class Listings: GEApproval.Models.CoursePrefix, GEApproval.Models.ICourse
{
public List<CoursePrefix> CoursePrefixObjList { get; set; }
public List<Course> CourseObjList { get; set; }
private GEApprovalDataModel _db;
//Constructor
public Listings()
{
_db = new GEApprovalDataModel();
}
//Generate a list of all courses associated with the prefix and place in ViewData model
public void listCourses(ViewDataDictionary viewData, int prefixID)
{
var test = _db.CoursePrefix.Include("Course").First(cp => cp.id == 1);
//Show total courses for this prefix
viewData.Model = test.Course.ToList();
viewData["prefix"] = test.Prefix;
viewData["courseCount"] = test.Course.Count;
int courseCount = test.Course.Count();//Test
}
}
}
And in my view, I now have the following line:
Inherits="System.Web.Mvc.ViewPage<List<GEApproval.Models.Listings>>"
I'm still a little confused because I still cannot access the properties of the Course object when listing them in my view, because I'm only inheriting directly from CoursePrefix. I'm not sure what I'm missing. Do I need to have a constructor for the composite object? Do I need the inherit and implementation statements for CoursePrefix and ICourse respectively if I'm already, supposedly, exposing the properties of each within the Listings wrapper class?
View 5 Replies
Mar 17, 2011
I'm using EF4 to generate a model. My architecture looks like this:
IMyEntity (custom interface)
-> MyEntity - EF generated class
IMyOtherEntity (custom interface)
-> MyExtendedEntity (Customn Partial class) : MyOtherEntity (EF Generated)
The first entity has a list of MyExtendedEntity. Is there any way I can bind this with the entity framework. I'm targetting ASP.NET and WPF. The main probnlem I have is that I need an ObservableCollection in WPF, while the EF generated class only has an EntityCollection which doesn't even seem to derive from ObservableCollection.
View 1 Replies
Oct 11, 2010
I think I know the answer to this but hoping someone has a neat solution. We are currently using two kinds of drop down controls (telerik and .net). I'm hoping to combine these into one control but struggling with a user friendly design.
Ideally the control would be created in the design file with a bool property of say "SimpleBox", to determine which kind of control to inherit. The instantiation would then be generated in the code behind design file and the constructor would then dynamically load the base (which isn't possible). The easy solution would be for me to create a IDropDown interface then have a factory create the correct one. The only real problem with this is the fact the instantiation has to be manually written every time. Which is a hassle, and does not speed up our process at all.
Although it isn't directly possible i'm looking for a solution along the lines of a factory which is ran inside the object constructor for setting the base, based on a bool property.
View 1 Replies
Oct 25, 2010
Am new bee to Webservices.I have declared complete BLL in the class library.
Can call those methods defined in Class library class files(.cs file) in .asmx file.
View 3 Replies
Oct 9, 2010
I have a solution with quite a few different MasterPages / BasePages which all inherit from somewhere else. My problem is that I have a virtual string in BaseMaster, which is overridden by BaseManagement, but when I try to access this string I always get the base valueThe point of inheriting masters and pages is obviously to avoid having duplicate code everywhere.
View 1 Replies
Oct 11, 2010
I am currently trialing EF4 code-first. My POCO classes inherit from an Audit class that contains CreatedBy, CreatedOn, UpdatedBy, UpdatedOn. I was hoping the framework would include the Audit properties in my Action table when creating my database, however this doesn't appear to be the case. Does anyone know how to enable this without overriding the OnModelCreating() method?
Public Class Audit
Public Property CreatedOn as DateTime
End Class
Public Class Action
inherits Audit
Public Property ActionId As Int32
End Class
View 1 Replies
Mar 27, 2011
I have created a Entity named MediaItem which is Abstract and Game inherits form it. I create the database automatically and I get a table MediaItems and MediaItems_Game.
The issue is when I do the following in my ASP.Net Controller:
private Models.DBContainer dataModel = new DBContainer();
dataModel. ---> Intellisense shows me MediaItem but I can find no way to either navigate to or use MediaItems_Game, how can I solve this? i.e. How can I grab a list of 'Games' with some 'WHERE' constraints on another table (not pictured).
View 1 Replies
Mar 4, 2010
I have ASP.NET Page - PageBase and some pages that inherits this page:
public class PageBase : System.Web.Page
public class SomePage : PageBase
I would like to have some controls placed in PageBase that every page that inherits from this page (like SomePage example) will have it displayed as well. This works perfectly in WinForms. If I place control (in designer mode) to WinForm A, I will get it displayed in form B - that inherits from A. This is perfect for building complex solution and I need to extend my WinForm solution to web.How will I do it in ASP.NET?
View 7 Replies
Sep 23, 2010
I have a problem with Master Page InherItance. I make master page Item and past Index in the source of Master page Item and Design of Master Page is Ok but in Web page , in Source , I whrit ,
Page
Language="C#"
AutoEventWireup="true"
MasterPageFile"~/MasterPage.master"
CodeFile="Default.aspx.cs"
Inherits="MasterPage"
but the Design of Web Page , isn't ok no Design , and I don Know What I can do with COde
View 8 Replies
May 20, 2010
I'm using VS2008, and I've got 10 ASP.NET 3.5 sites which all have a virtual directory which maps to one ASP.NET 3.5 subsite.
I'm trying to get a WCF service to work with client-side ajax on the subsite. I've modified my web.config file on the subsite to use baseAddressPrefixFilters, but I can't get this to work with every site. For example, I can add an entry for one site, but the ajax calls will only work for that one site. All the other sites will fail.
View 3 Replies
Mar 21, 2010
I'm trying to add a IsImage property that I wrote myself to the HttpPostedFile class, so that if a user is uploading a file, I can do something like this:FileUpload1.PostedFile.IsImageHow can I do that in C#?
View 1 Replies
Oct 22, 2010
I have a base page called let's say Login.aspx with Login.aspx.cs code behind.Now...I would like to derive page from that page for several specyfic customers. Basically nothing changes in layout (aspx file), the only think is difference in handling Page_Load event. However when I access my derived login page LoginClientName.aspx no output is rendered - my aspx file contains only:
<%@ Import Namespace="System" %>
<%@ Page Language="c#" Inherits="StandardPages.Login"%>
<script runat="server">
[code]...
View 1 Replies
Oct 7, 2010
I have a table which houses two entities. StaticProgram and DynamicProgram. There is one column in that table called ProgramType which determines if a program is of Type static or Dynamic. Though these two entities are stored in one table (I am guessing because the primitive fields for Static and Dynamic programs are exactly the same) but from a business point of view these are two VERY different entities.
So, I created two Classes StaticProgram and DynamicProgram. However, I donot want to create two seperate Data Access Classes because it is going to be the exact same code replicated twice. I tried creating a "Program" class as base class and inherited StaticProgram and DynamicProgram classes but down casting is not supported so I can't return a "Program" object from the data access class and cast it to "StaticProgram" class.So, what are my options? Can I create an IProgram interface and have StaticProgram and DynamicProgram implement that interface and have my Data Access class return IProgram?
View 1 Replies
Feb 17, 2010
Difference beteween AbstractClass and InterFace and Inheritence. And What is the major role of these in OOPS Concepts.
View 1 Replies
Mar 12, 2010
I have a Consumer class and a BillableConsumer : Consumer class. When trying to do any operation on my "Consumers" set, I get the error message "Object mapping could not be found for Type with identity Models.BillableConsumer.
From the CSDL:
[code]....
Is this because I did not specifically add the BillableConsumer entity to the object set? How do I do that in a POCO scenario?
View 1 Replies
Nov 19, 2010
What is the reason that mulitple inheritance is not allowed in .net.
View 2 Replies
Nov 3, 2010
I have found some information regarding this but not enough for me to understand what the best practice for is for this scenario. I have your typicaly TPH setup with an abstract base class "Firm". I have several children "Small Firm", "Big Firm" etc inheriting from Firm. In reality I actually have different realistic classifications for firms but I am trying to keep it simple in this example. In the database as per TPH I have a single Firm table with a FirmTypeId column (int) that differentiates between all these types. Everything works great except I have a requirement to allow a user to change one type of firm into another. For example a user might have made a mistake when adding the firm, and would like to change it from Big Firm to Small Firm. Because entity framework does not allow exposing the discriminating database column to be exposed as a property, I don't believe there is a way to change one type into another via EF. The way I see it I have two options:
Don't use TPH. Simply have a Firm Entity and go back to using .Where(FirmTypeId == something) to differentiate between the types. Execute SQL directly using context.ExecuteStoreCommand to update the FirmTypeId column of the database.
I've seen a post where people suggest that One of the tenets of OOP is that instances cannot change their type. Although that makes perfect sense to me, I just don't seem to be able to connect the dots. If we were to follow this rule, then the only time to use any kind of inheritance (TPH/TPT) is when one is sure that one type would never be converted into another. So a Small Firm will never become a Big Firm. I see suggestions that composition should be used instead. Even though it doesn't make sense to me (meaning I don't see how a Firm has a Big Firm, to me a Big Firm is a Firm), I can see how composition can be modeled in EF if the data is in multiple tables. However in a situation where I have a single table in the database it seems it's TPH or what I've described in #1 and #2 above.
View 2 Replies
Oct 19, 2010
I've got an entity that inherits from another, but for some reason the entity that is inheriting isn't showing as an available object? The parent entity is "Customer" and the child entity is called "RetailCustomer", but only "Customer" will show in intellisense as being available? I'm currently using:
[Code]....
And really need to be using something like this...
[Code]....
but VS comes back telling me that RetailCustomers isn't a member of my Entities Context.
View 4 Replies
May 27, 2010
I'm working on a web application. One of my co-workers has written some asp.net forms pages. The page classes all inherit from BasePageClass, which of course inherits from the Page class. I wish to add some MVC controllers that I've been told need to use the same logic implemented in the BasePageClass. Ordinarily, I would want to inherit the functions in the BasePageClass in the controller classes, but this breaks the inheritance heirarchy.
View 1 Replies
Aug 2, 2010
Let's say in ASP.NET you have a base page class which defines a private Page_Load method which handles Page.Load. All aspx pages in your project inherit from this base page class. In this case the aspx pages would be able to call this private method. However it does not feel right that private methods can be called outside its own class? If so, privates methods cannot be hidden from outside?
View 1 Replies