Why does the editor provide different sections and input types for bytes and small, as shown here:
& lt; Div class = "form-group" & gt; & Lt; Input class = "text box one-line" data-val = "true" data-wall-number = "field number year / period should be a number." Id = "NumYear_Period" name = "NumYear_Period" type = "number" value = "" /> & Lt; / Div & gt; & Lt; Div class = "form-group" & gt; & Lt; Input class = "form-control" data-val = "true" data-val-number = "field start year must be a number." Id = "Start_Year_Period" name = "Start_Year_Period" type = "text" value = "" /> & Lt; / Div & gt; "NumYear_Period" is a nullable byte and "Start_Year_Period" is a qualified small: [display (name = "number year / duration")] Public Nullable & lt; Byte & gt; NumYear_Period {Receive; Set; } [Display (name = "start year")] Public taps qualified & lt; Short> Start_Year_Period {Receive; Set; }
Create.cshtml view includes:
& lt; Div class = "form-group" & gt; @ Html.EditorFor (model => model.NumYear_Period) & lt; / Div & gt; & Lt; Div class = "form-group" & gt; @ Html.EditorFor (model => model.Start_Year_Period) & lt; / Div & gt;
I do not have any editor templates, so why!
Bootstrap, Visual Studio 2013 Update 1, MVC 5.1.1, Net 4.5, RAZR 3.1.1
This renders differently because there is no specific template for short
or System.Int16
in _defaultEditor verbs System.Web.Mvc.Html.TemplateHelpers
in the private collection of code>. The only error is: "hidden input", "multiline text", "password", "text", "collection", "phone number", "url", "email address" , "Date", "date", "time", typef (byte) .name, type sbyte. Name, typef (int) .name, typef (uit) .name, typef (long) .name, typef ( Ulong). Name, typef (boole) .name, typef (decimal) .name, typef (string) .name, type of (object) .name,
As you said earlier you have There is no editor templates for MVC framework, there is no other way for you to render a default input tag.
A file to renderig specific to a short
datatype to a file Int16
folder in the EditTemplates folder under its view folder or with the following content HTTPS Under:
@model short @ Html.TextBox ("", ViewData.TemplateInfo.FormattedModelValue, new {@ type = "number"})
This will introduce lower
type to your model
Alternatively, you can make the property of your model alike: [display (name = "start year")] [UIHint ("int32")] Public Nullable & lt; Short> Start_Year_Period {Receive; Set; }
which basically gives TemplateHelper instructions to use the int
type (or System.Int32
for full)
>
Comments
Post a Comment