Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9191869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:47:26+00:00 2026-06-17T20:47:26+00:00

@model MyMVC.Models.MyMVC.MyModel @{ ViewBag.Title = Index; } The reason why I ask this question

  • 0
@model MyMVC.Models.MyMVC.MyModel

@{
    ViewBag.Title = "Index";
}

The reason why I ask this question is in MVC we can have more than 1 form, so I would like to have a model for each form. But when I was trying to add another model at the top of the view, it displays an error.
I know we can use ViewModel which has model1 and model2 inside, but it’s not the question I am asking.

I just simply want to know is there any way that we can put in 2 models into 1 view.

Update:

For example, I want to have 2 forms in my view, so for each form I’d like to have a separated model.

Update 2
Thank you all for your replies. I now know that MVC only supports one single model on one view. Do you guys consider this a disadvantage of MVC? Why or Why not?(No one has answered it yet…. why?)

Your answers are similar, so I don’t even know which one should be set as an answer.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:47:27+00:00Added an answer on June 17, 2026 at 8:47 pm

    You should use some prtialviews for other models. You have your main view with main model. Inside of that view, you could have some partialviews with their models and their validations.

    ————————————–Edit:

    As others said it is better to use View Models and combine the models with each others. But as you wanted I created a sample project for you on my Github account:

    https://github.com/bahman616/ASPNET_MVC_multiple_models_in_a_view_with_partialview.git

    Here is the simplified code of that project:

    Here are two models:

    public partial class Person
    {
        public int ID { get; set; }
        [Required]
        public string Name { get; set; }
    }
    public partial class Company
    {
        public int Id { get; set; }
        [Required]
        public string Name { get; set; }
    }
    

    I want to have both create views in one view, so this is the parent view:

    @model ASP_NET_MVC_Multiple_Models_In_A_View.Models.Person
    
    @{
        ViewBag.Title = "Create";
    }
    
    <h2>Create</h2>
    
    @using (Html.BeginForm("Create","Person")) {
        @Html.ValidationSummary(true)
    
        <fieldset>
            <legend>Person</legend>
    
            <div class="editor-label">
                @Html.LabelFor(model => model.Name)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Name)
                @Html.ValidationMessageFor(model => model.Name)
            </div>
    
            <p>
                <input type="submit" value="Create" />
            </p>
        </fieldset>
    }
    
    <div>
        @Html.ActionLink("Back to List", "Index")
    </div>
    
    @{Html.RenderAction("_CompanyCreate", "Company");}
    
    @section Scripts {
        @Scripts.Render("~/bundles/jqueryval")
    }
    

    And this is the partial view:

    @model ASP_NET_MVC_Multiple_Models_In_A_View.Models.Company
    
    <script src="~/Scripts/jquery-1.7.1.min.js"></script>
    <script src="~/Scripts/jquery.validate.min.js"></script>
    <script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
    
    @using (Html.BeginForm("_CompanyCreate","Company")) {
        @Html.ValidationSummary(true)
    
        <fieldset>
            <legend>Company</legend>
    
            <div class="editor-label">
                @Html.LabelFor(model => model.Name)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Name)
                @Html.ValidationMessageFor(model => model.Name)
            </div>
    
            <p>
                <input type="submit" value="Create" />
            </p>
        </fieldset>
    }
    
    <div>
        @Html.ActionLink("Back to List", "Index")
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question about the 'Models' folder or layer in a ASP.NET MVC
In my MVC 4 project, I have a Model like: public class MyModel {
In my MVC application I have a View Model that looks similar to this:
I have a problem with my MVC 4 Application. I have a Model with
I have the following snippets in my MVC 3 website. Model: public class Item1
So I have a ViewModel in the 'models' folder of my Mvc project with
I am just extending my this question a bit. I have my App_LocalResources in
I'm looking for a simpler/drier way to use ressources my MVC 3 models. This
I have a page on my MVC application where a user can edit /
This is my MVC model: public class Link { [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public Guid ID {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.