开发者

Does ASP.NET MVC ViewPage or ViewUserControl allow multiple inheritence

开发者 https://www.devze.com 2022-12-12 04:38 出处:网络
I have one Viewpage where I inherit List version of my model class to show a list of products. Now on the same page I want to create a form for which I need to use my model class properties. As I\'m u

I have one Viewpage where I inherit List version of my model class to show a list of products. Now on the same page I want to create a form for which I need to use my model class properties. As I'm using a List version of model class, I'm not being able to get the properties without iterating the items in Model. I tried creating an UserControl inheritting the model class itself and use <%Html.RenderPartial("UserControl"); %> in my list class. But it gives runtime 开发者_运维问答error. How to avoid this situation?? Please help.


No you can do it by creating a composite model object containg your first model and your second one

In your page directive: ViewPage<YouCompositeModelType>

in your page: <% Html.RenderPartial("YourPartialViewName", Model.YourSecondModelObject); %>

0

精彩评论

暂无评论...
验证码 换一张
取 消