Melursus
Melursus

Reputation: 10578

Asp.Net MVC RenderPartial different model

I got a view that inherits : System.Web.Mvc.ViewPage<IEnumerable<MyProjects.Models.MyAccountWrapper>>

In this view I list data about the object MyAccountWrapper. This object contains a list of Account. Like this MyAccountWrapper.Accounts

What I would like in this view is to be able to create an account.

So I Try <% Html.RenderPartial("../Account/Create"); %>

But I got error about is not the good model. How can I deal with that ?

Upvotes: 1

Views: 4224

Answers (2)

baretta
baretta

Reputation: 7585

Try passing the appropriate model as second parameter when calling RenderPartial.

Upvotes: 5

Robert Harvey
Robert Harvey

Reputation: 180787

I suggest that you create a new controller and view that corresponds to "../Account/Create". This pins the URL for that action to a specific view. The user will perceive this as a separate and distinct action, which in fact it is. You can then return them to where they were by using a ReturnUrl technique, if you wish.

In other words, you need a brand new page for this.

Upvotes: 1

Related Questions