Is it possibile to inherit from multiple classes in the same VIEW. i have many classes that mirror my database tables with linq to sql and as i m doing a register page(THE VIEW), which needs multiple classes i need to find a way to inherit more than 1?
tnx to all
Inheriting from multiple classes in a VIEW
Page 1 of 11 Replies - 1849 Views - Last Post: 03 August 2012 - 08:00 PM
Replies To: Inheriting from multiple classes in a VIEW
#2
Re: Inheriting from multiple classes in a VIEW
Posted 03 August 2012 - 08:00 PM
well you definitely cannot inherit from more than one class in C#. You can implement multiple interfaces but you can only inherit from one class. However, if you are needing to pass multiple objects to your view you can do so using a composite class. This would allow you to pass a single object that contains instances of the different objects you need rather than using a class that inherits from all of the different classes you need to pass to the view.
Then in the view would access each object using dot notation just as you would any other property.
public class RegisterViewModel
{
public ClassOne ExampleOne {get;set;}
public ClassTwo ExampleTwo {get;set;}
public ClassThree ExampleThree {get;set;}
}
Then in the view would access each object using dot notation just as you would any other property.
Model.ExampleOne.PropertyOne
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|