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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:15:00+00:00 2026-05-30T08:15:00+00:00

I am aware of this question , but the original poster accepted a solution

  • 0

I am aware of this question, but the original poster accepted a solution that didn’t involve nesting. I definitely want to nest partial views (unless, of course, there’s a better way.)

I have a page that can Ajax-load one of several partial views, depending on the user’s actions in the main view. (The views are partial because my understanding is that if you want to load significant additional content from an Ajax call, you need to return a PartialViewResult from your call.) The several partial views have one common element, a dropdown, which I’d like to factor out into its own partial view.

But this isn’t working. My partial views each have an associated view model, which is their model. For the nested partial view, I’d like to pass the value of a single field, a nullable int, from the parent view’s view model, as the model for the nested partial view.

But at run time I get an error saying that my partial view needs a Nullable<int> but received X, where X is the type of the view model associated with the parent partial view.

So my question is twofold:

  1. Is nesting partial views simply not allowed? (In which case, I wish the framework would check for the situation and throw an error that says so explicitly.)

  2. Is there a way to get the effect I want, of a factored-out common interface element, other than with a partial view? I have considered, but not tried, creating an edit template, because I believed that what wouldn’t work for partial views wouldn’t work for those, but I could be wrong.

ETA: I found my problem: when you pass a null value for the model into HtmlHelper.Partial or RenderPartial, the rendering engine subsitutes the model of the calling partial view in place of that null, assuming that you simply didn’t pass a model.

Which is not true in my case: my Nullable<int> is Nullable because, until it’s set, it’s null! The null is semantically meaningful!

But this is why I was having the problem.

  • 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-05-30T08:15:02+00:00Added an answer on May 30, 2026 at 8:15 am

    Yes, you can nest partial views. Just make sure you pass in the correct model. HtmlHelpers are useful here, as you can encapsulate the call to RenderPartial with the full view path and ensure the correct model is used.

    example

    public static void RenderSomePartial(this HtmlHelper helper, int? i)
    {
        helper.RenderPartial("~/Views/Shared/SomePartial.cshtml", i);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I aware that this will be a less programming question, but still... How can
I'm aware that there probably isn't a perfect solution to my question (this sounds
I'm aware that this question may have been asked before, but I still haven't
In this question , I was made aware of glob()'s GLOB_BRACE option that allows
In the answer to this question ovanes states: Please be aware that boost::lexical_cast is
I'm aware that MD5 has had some collisions but this is more of a
This is probably a question that is more about object alloc/retain/release, but I'll use
I'm aware of this question here but I have a slightly different question. If
I am aware of this question , but it does not appear to work
I'm aware of this question, and it's follow-up, and also this one, but I

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.