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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:47:46+00:00 2026-05-16T23:47:46+00:00

I’ve been reading Scott Guthrie’s post on Passing ViewData from Controllers to Views ,

  • 0

I’ve been reading Scott Guthrie’s post on Passing ViewData from Controllers to Views, but I don’t think the lesson is clicking for my specific situation.

(Note: Due to client proprietary restrictions, I can’t talk paste the actual code, so I apologize if my made up case is a bit stupid/confusing.)

I have a Controller called ScenarioController which handles the various actions revolving around the creation of a Scenario model. Various actions a user will complete are the general CRUD of Scenarios. I can create a website that does this for the Scenario model. However, I recently updated the Scenario model so that it is now made up of various sub-components (lists of other objects). The corresponding view utilizes jQuery Tabs which load partial views to, ultimately, load the forms to the various sub-component data. Unfortunately, this is where I am having trouble.

My Index page currently looks something like this:

<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

<% using (Html.BeginForm()) {%>
    <div id="scenario">
        <div id="tabs">
            <ul>
                <li><a href="#tab1">Tab 1</a></li>
                <li><a href="#tab2">Tab 2</a></li>
                <li><a href="#tab3">Tab 3</a></li>
            </ul>

            <div id="tab1"><% Html.RenderPartial("Tab1"); %></div>
            <div id="tab2"><% Html.RenderPartial("Tab2"); %></div>
            <div id="tab3"><% Html.RenderPartial("Tab3"); %></div>
        </div>

        <div class="submitButtons">
            <input type="button" value="Save Scenario" id="SaveScenario" />
            <input type="button" value="Submit Scenario" id="SubmitScenario" />
        </div>
    </div>
<% } %>
</asp:Content>

And the partial pages are strongly-typed to whatever they represent (primarily List<SomeObject>).

How should the data be stored within the Scenario model? I am using a SQL database and interfacing with Entity Framework. Do I still need Properties representing the various lists of items (so I can pass ViewData using strongly typed classes), or is this something I can pass in the ViewData directly from the entity calls (and cast as needed)?

  • 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-16T23:47:46+00:00Added an answer on May 16, 2026 at 11:47 pm

    You can pass as many models as you want in your view. you just have to make an encapsulating model which can contain all your ‘to send’ models.

    you can also make use of ViewData but using a model is recommended.

    Do your 3 tabs need the whole model or just a part of it?

    let’s say you have 3 models in your encapsulating model. named tab1 tab2 tab3.

    so then you could send each Renderpartial it’s appropriate model as so:

            <div id="tab1"><% Html.RenderPartial("Tab1", Model.tab1); %></div>
            <div id="tab2"><% Html.RenderPartial("Tab2", Model.tab2); %></div>
            <div id="tab3"><% Html.RenderPartial("Tab3", Model.tab3); %></div>
    

    your encapsulating model could then look like

    namespace MVCNAMESPACE.Models {
        public partial class EnCapModel {
            public List<SomeObject> tab1 { get; set; }
            public List<SomeObject> tab2 { get; set; }
            public List<SomeObject> tab3 { get; set; }
        }
    }
    

    hope this helps

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

Sidebar

Related Questions

I have a view passing on information from a database: def serve_article(request, id): served_article
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but

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.