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 7779953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:46:58+00:00 2026-06-01T18:46:58+00:00

Is it possible for an mvc razor partial view to take in one of

  • 0

Is it possible for an mvc razor partial view to take in one of 2 models….I have a create template and an edit template, they’re similar but not the same. So i’ve created a common partial view, extracted the similar items into that, but it requires a model. I want this partial to be able to take in either a create model or edit model depending on where it’s being called from.

So in my create view i would say
@{Html.Partial("EditorTemplates/CommonModel", Model);}
where model is my create model

and in the edit
@{Html.Partial("EditorTemplates/CommonModel", Model);}
where model is my edit model…
how should i define the model on the partial to cater for this?

  • 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-01T18:46:59+00:00Added an answer on June 1, 2026 at 6:46 pm

    Sounds like a perfect case for inheritance. Create a base class with everything you need for your commonly held partial in it. Have both your editor model and your create model inherit from it. Define the base class as the model for the partial view. Pass whichever child class (create or edit) model you happen to have into your Html.Partial call.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to use Razor View Engine (ASP.NET MVC) together with .LESS (similar
I have an MVC 3 Razor partial page that is dependent on jquery.validate.js and
Is it possible to assign javascript variable to c# variable in mvc razor view?
Is it possible to create a single line iteration command in my non-razor MVC
is it possible in MVC to setup a site where it would have one
I am wondering if the following is possible in MVC 3 I basically have
Possible Duplicate: Client Id for Property (ASP.Net MVC) In my View I'm using jquery
Is it possible to create ASP.NET MVC applications in VS 2010? What should I
Is it possible to have multiple resource bundles in spring mvc? I want to
I am just new to MVC. when we use @Html.EditorFor in razor view, it

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.