Home Textbox of editorfor htmlhelper is different for integer type
Reply: 0

Textbox of editorfor htmlhelper is different for integer type

user10302 Published in September 19, 2018, 11:01 am

I am using to Editorfor for displaying values of a class in the view. I am using MVC . While the textbox properties and appearance are the same for values of string type, the textbox appearance for value of integer is changed and not consistence with the other textbox appearances. I have uploaded a snap of the view as well as the code.

                @Html.LabelFor(model => model.Id, "Project Id", new { @class = "control-label" })


                    @Html.ValidationMessageFor(model => model.Id)

                @Html.LabelFor(model => model.Name, "Project Name", new { @class = "control-label" })
                    @Html.EditorFor(model => model.Name, new { @readonly = "readonly" })
                    @Html.ValidationMessageFor(model => model.Name)

enter image description here

share|improve this question
  • Because EditorFor() add type="number" for int, and type="text" for string – Stephen Muecke Apr 17 at 10:06
  • @StephenMuecke How to change the appearance to keep in consistence with the other textboxes. I tried overriding the type as text. It still did not help. – Dannyboi Apr 17 at 10:08
  • I have no idea what your css is, but you could start by using @Html.TextBoxFor(m => m.Id) – Stephen Muecke Apr 17 at 10:09
  • @StephenMuecke Hi, I tried TextBoxfor=> , all it did was increase the size of the textbox. Is there any work-around? like converting the int type to string in the view. – Dannyboi Apr 17 at 10:12
  • That has nothing to do with it - Its a styling issue - i.e. your css (and you have not shown any of it!) And tables are for tabular data, NOT layout – Stephen Muecke Apr 17 at 10:14

1 Answer 1

active oldest votes
up vote 0 down vote
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.47075 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO