Answer the question
In order to leave comments, you need to log in
How to generate two forms with different models in ASP.NET MVC 4?
I'm trying to generate 2 forms, but I can't figure out how to do it. If I get the first form, then I can’t figure out the second one. Forms are filled with different models. But everywhere on the Internet there are examples with only one model. For example,
@model MvcApplication.Models.Post
@model MvcApplication.Models.Category
<form>
@Html.TextBoxFor(model => model.Title)
</form>
<form>
@Html.TextBoxFor(model => model.Name)
</form>
Answer the question
In order to leave comments, you need to log in
There are many options for solving the problem: stackoverflow.com/questions/4764011/multiple-model...
As the simplest:
@model Tuple<MvcApplication.Models.Post, MvcApplication.Models.Category>
can you do that
public class PostCategoryViewModel
{
public Post Post {get;set;}
public Category Category {get;set;}
}
@model MvcApplication.Models.PostCategoryViewModel
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question