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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:06:35+00:00 2026-05-15T23:06:35+00:00

I am using MVC2 in VS2010 with .Net 4.0. I have a situation in

  • 0

I am using MVC2 in VS2010 with .Net 4.0. I have a situation in which I will have a bunch of partial views that I need to all have the same template. Basically I need them all wrapped with the same DIV (and other junk). I just want one place to change this DIV… so I used a master page. It works great, all the partial views use that master, and if I need to change something its no problem.

Problem space: I need to have some of the View specific data, in this case its the Id of the record the view displays, shown in the Id id the DIV. Now I realize I could just create another placeholder, but I need this id to be in 10 places, not 1.

<div id="<%: ViewObjectId %>">
  <asp:contentplaceholder id="ViewStuff" runat="server"/>
</div>

I have tried to add the Id to the ViewData, however it seems in MVC2 the ViewData is missing in action.

I could create a parent Action that calls a child view, but the problem with that is it takes away from the flexibility of having any parameters I want… all views would have to use the same signature.

Any thoughts or suggestions?

  • 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-15T23:06:36+00:00Added an answer on May 15, 2026 at 11:06 pm

    Not sure what you mean by “however it seems in MVC2 the ViewData is missing in action.” ViewData is there and should work for what you want. You’ll have to access it as ViewData["ViewObjectId"] if you want it, though.

    If this doesn’t work, could you post code samples to show how you are trying to set the ViewData value?

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

Sidebar

Related Questions

I'm using MVC2 with VS2010 I have a view that has two partial views
I have a web application which was using Asp.net MVC2 . I Upgraded it
I have installed VS2010 and MVC2 and testing a simple form using tinyMCE. When
I am using ASP.NET MVC2 with NHibernate, but am facing an issue. All calls
[NOTE: I'm using ASP.NET MVC2 RC2.] I have URLs like this: /customers/123/orders/456/items/index /customers/123/orders/456/items/789/edit My
I'm working on a ASP.NET MVC2 project, for which I have configured the localisation
I have an MVC 2.0 application that I'm playing around with in VS2010 which
I'm using MVC2 and Entity Framework. I have 2 Entity Collections and I need
I have a dropdownlist in my asp.net MVC2 view like this: <% using(Html.BeginForm(temp,Settings)){ %>
I'm using MVC2, Preview 2. Why is it that when I use: <%= Html.LabelFor(x

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.