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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:24:00+00:00 2026-06-11T09:24:00+00:00

In a view I’m using this overload of HtmlHelper.TextBox : public static MvcHtmlString TextBox(

  • 0

In a view I’m using this overload of HtmlHelper.TextBox:

public static MvcHtmlString TextBox(
    this HtmlHelper htmlHelper,
    string name,
    Object value
)

The documentation states:

value

Type: System.Object

The value of the text input element. If this value is null, the value of the element is retrieved from the ViewDataDictionary object. If no value exists there, the value is retrieved from the ModelStateDictionary object.

I do provide a value when I call this overload, and this value is not null. Nevertheless, the value for the textbox is retrieved from the ModelStateDictionary whenever it is present there.

In order to force the textbox to use the value provided inline, I have to reset the model first in the controller (or remove the key with the textbox’s name from the keys collection).

Same applies to other controls rendered by HtmlHelper.

Where is my understanding wrong? Or is that a bug in the documentation?

  • 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-11T09:24:01+00:00Added an answer on June 11, 2026 at 9:24 am

    ModelState always has precedence in all input helpers, not just TextBox. This allows you to specify a default value in the view, and after POST render the posted value (taken from ModelState) without having to manually pass the posted value to the view. To use a different value you must remove the entry from ModelState.

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

Sidebar

Related Questions

View Looks Like This <?=form_open_multipart('upload/process');?> <input type=file multiple=multiple name=userfile[] id=userfile /> <?=form_submit('upload', 'Upload');?> <?=form_close();?>
View: Playing with a basic calculator using WPF(MVVM). I've 1 TextBox for the first
View this code: function testprecision(){ var isNotNumber = parseFloat('1.3').toPrecision(6); alert(typeof isNotNumber); //=> string }
View Model: public class Note { [DataType(DataType.MultilineText)] public string Text { get; set; }
public View getView(int position, View convertView, ViewGroup parent) { Button btn; if (convertView ==
In view: <%= text_field_with_auto_complete :vendor, :number, {}, {:with => 'vendor[number]=' + $('vendor_number').value} %> In
my View constructor: public View1(IRegionManager regionManager, IUnityContainer container, bool myParam) { } How to
custom view: public class MyView extends AbstractView { .... awesome stuff ... } controller:
{{view Ember.Select contentBinding=ResAdmin.adminController.priceCategories valueBinding=selectedRestaurant.PriceCategoryID optionLabelPath=content.name optionValuePath=content.id}} how can i add the default value like
VIEW <h:form id=main_form> <p:inputText id=title required=true label=Title value=#{myBean.myLink.title} immediate=true /> <p:selectOneMenu id=scope required=true label=Scope

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.