asp.net mvc 4 - editorfor picks string template instead of double -


i'm having issues view model in project contains number of doubles in them

ie.

public class myviewmodel {     public double left { get; set; }     public double right { get; set; }     public double top { get; set; }     public double bottom { get; set; } } 

in view have

@html.editorformodel 

if there no other custom templates in project renders correctly , textbox double on in it.

as put string template in view/shared/editortemplate , put inside of whatever in template gets rendered instead of double template.

i have thought though have overriden string template order selecting templates remain same, , double template choosen before string template existed.

the string template consisted of (no @model )

<h2>string</h2> 

am missing here, why string template choosen here?

i've determined can put double template in views shared folder , render instead seems shouldn't have that.

edit:

as per darin's answer created own double editortemplate based on decimal template.

@using system.globalization @functions {      private object formattedvalue     {                 {             if (viewdata.templateinfo.formattedmodelvalue == viewdata.modelmetadata.model)             {                 return string.format(cultureinfo.currentculture, "{0:0.00}", viewdata.modelmetadata.model);             }             return viewdata.templateinfo.formattedmodelvalue;         }     }  }  @html.textbox("", formattedvalue, new {@class = "text-box single-line"}) 

am missing here, why string template choosen here?

in both cases it's string template being chosen. there's no default template double type. here's how default string template looks like:

@html.textbox(     "",      viewdata.templateinfo.formattedmodelvalue,     new { @class = "text-box single-line" } ) 

i've determined can put double template in views shared folder , render instead seems shouldn't have that.

well, if not satisfied default template double type (which string.cshtml) write custom template it.


Comments

Popular posts from this blog

c++ - End of file on pipe magic during open -

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -