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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:08:24+00:00 2026-06-06T01:08:24+00:00

If I am using a ViewBag which contains a strongly typed object, is there

  • 0

If I am using a ViewBag which contains a strongly typed object, is there any way on MVC Razor to define (or cast this) so that all the elements of that appear in the IntelliSense?

For example lets say I have

ViewBag.Movies.Name
ViewBag.Movies.Length

I know Movies is of object type Movie, which has the members Name and length

class Movie { 
    public string Name {get; set;}
    public string Length {get; set;}
}

Can I somehow cast this, like I do for model

@model Transactions.UserTransactionDetails

So that the members of Movie become available in Razor?

  • 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-06T01:08:25+00:00Added an answer on June 6, 2026 at 1:08 am

    Use a ViewModel, which contains properties for all the different objects that you view needs

    e.g.

    public class MovieTransactionViewModel 
    {
       public List<Transaction> Transactions { get; set; }
       public List<Movie> Movies { get; set; }
    }
    

    Then, have your view use this as it’s model, and you will get intellisense in your view.

    That way you are not changing your models, so EntityFramework will not be affected.

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

Sidebar

Related Questions

Having created dropdown lists using ViewBag which is working in an edit form. How
I'm using a global filter to handle errors in ASP.NET MVC 3 (with Razor
In ASP.MVC 3 or 4 (using Razor), how do you apply a CSS Class
I make heavy use of the ViewBag in my MVC application, is this considered
I have a Search Edit view which is strongly typed to my Search model
I'm using ViewBag.Message with the same message several times into the methods on the
using (var file_stream = File.Create(users.xml)) { var serializer = new XmlSerializer(typeof(PasswordManager)); serializer.Serialize(file_stream, this); file_stream.Close();
Using Flex 3, I would like to take an image snapshot such as this:
My application is in Asp.Net MVC3 coded in C#.Net. I have Views which contains
I am trying to render a ViewModel using Razor and MVC3. For some reason

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.