1

I have a partial view that is shared between two controllers and I'm trying to find a way to change what it inherits from depending on which view it is being called from or which controller.

IE:

my current partial is started like so:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<MVCProject.Controllers.PurchasingOrderViewModel>" %>

and i would like it to also be able to inherit from another class because of needing the same info in two separate controllers

Any ideas?

Thanks

1 Answer 1

3

I think the best way is to introduce a common interface or an abstract class for MVCProject.Controllers.PurchasingOrderViewModel and your other model like:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<MVCProject.Controllers.IOrderViewModel>" %>
Sign up to request clarification or add additional context in comments.

1 Comment

yeah that's what i was originally thinking, was hoping there was something slightly easier, although that's not too bad. Thanks

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.