64708

“null” values shown in form fields in IE

I use Html helpers to display model data in form fields, e.g. Html.TextBoxFor, Html.TextAreaFor.

When the model values are null, I would expect the values should be empty in the form fields. They are displayed normally in Safari and Firefox, i.e. empty, but in IE, they are shown as "null" in a text field (see image below).

<img src="https://i.stack.imgur.com/Yxiyl.png" alt="enter image description here">

Any clue how to fix this? Thanks.

Answer1:

Well, it turned out to be JavaScript's problem (with IE, that is). In the following statement, if value == null, IE would display null in the textbox (or textarea).

$('#someTextBox').val(value);

The quick fix is simply display an empty string instead...

$('#someTextBox').val(value == null ? '' : value);

Recommend

  • How to add extra data to the ckeditor using jquery?
  • Strange validation problems with a Ajax/jQuery postback in ASP.NET MVC 3
  • Cursor in wrong place in contenteditable
  • Is it safe to drop the -webkit vendor prefix from the css3 border-radius yet?
  • You tube videos are not playing
  • Returning the auto incrementing value after an insert using slick
  • Django model for a Postgres view
  • Activation Function choice for Neural network
  • How to getText() from the input field of an angularjs Application
  • AppleScript : find open tab in safari by name and open it
  • Combining two different ActiveRecord collections into one
  • Angularjs pass function from Controller to Directive (or call controller function from directive) -
  • Django invalid literal for int() with base 10
  • Eloquent paginate function in Slim 3 project using twig
  • Eloquent update method change created_at timestamp
  • AJAX Html Editor Extender upload image appearing blank
  • How to use remove-erase idiom for removing empty vectors in a vector?
  • Chrome doesn't support silverlight anymore? How to solve this?
  • The plugin 'org.apache.maven.plugins:maven-jboss-as-plugin' does not exist or no valid ver
  • Repeat a vertical line on every page in Report Builder / SSRS
  • Why is an OPTIONS request sent to the server?
  • Display issues when we change from one jquery mobile page to another in firefox
  • Ajax jQuery multiple calls at the same time - long wait for answer and not able to cancel
  • Window Size for Mac application
  • To display the title for the current loaction in map in iphone
  • Traverse Array and Display in markup
  • Linker errors when using intrinsic function via function pointer
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • How to set the response of a form post action to a iframe source?
  • Understanding cpu registers
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • LevelDB C iterator
  • Bitwise OR returns boolean when one of operands is nil
  • MATLAB: Piecewise function in curve fitting toolbox using fittype
  • Recursive/Hierarchical Query Using Postgres
  • Running Map reduces the dimensions of the matrices
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • Binding checkboxes to object values in AngularJs
  • How can i traverse a binary tree from right to left in java?
  • How can I use `wmic` in a Windows PE script?