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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:33:20+00:00 2026-05-20T07:33:20+00:00

There seems to be an issue with the ViewBag dynamic properties. Lets say I

  • 0

There seems to be an issue with the ViewBag dynamic properties. Lets say I have:

@{
    ViewBag.Title = @Model.CourseName;
}

And then in a form on the page I have:

@Html.TextBox("Title", null, new {style="width:400px;"})

Where Title is the name of a field in a database table.

When the page first opens, text box with an id of “Title” takes the value of the ViewBag.Title dynamic property.

I am a bit hazy on the exact details of Model Binding, but this does seem to be a bug, or if not, if it is something that occurs naturally as a result of the binding process, then it would be nice to be warned of this.

The work around I found, was to rename the ViewBag property to:

@{
    ViewBag.Titulo = @Model.CourseName;
}

(Title changed to Titulo – Always good to know another language to avoid name clashes…)

And the issue went away.

However, the question is:

Is this behaviour to be expected? The bug was easy to find (took an hour to figure it out, including writing this question), but I suspect that other bugs might be more, uhmmm, recondite.

EDIT:

Rephrasing the question:

Does the Model Binder automatically bind properties it finds in the ViewBag? Even when an existing property exists in the strongly typed ViewModel I have passed to the page? Surely the ViewModel should take preference?

  • 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-20T07:33:20+00:00Added an answer on May 20, 2026 at 7:33 am

    Html.TextBox checks ViewData/ViewBag values first, then Model. To make sure it takes Model value, you must use Html.TextBoxFor.

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

Sidebar

Related Questions

I have VS.NET 2010 Premium installed, but there seems to be an issue when
I have an issue with model binding a checkbox from a form to an
There seems to be an issue simulating the backspace key with java.awt.Robot . This
In my app after a while, there seems to be a huge issue. There
I have a survey on a website, and there seems to be some issues
There seems to be an issue around generating IDs with indexers within the MVC
So there seems to be an issue with animating size transformations for UIButtons. Specifically,
There seems to be an issue with my dequeue function within a queue class
I have implemented this Feature Content Slider: http://demo.webdeveloperplus.com/featured-content-slider/ There seems to be space between
Second Update After doing some more digging, there seems to be a bigger issue

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.