Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Smart EditorFor
Message
 
 
To
21/12/2012 10:38:22
General information
Forum:
ASP.NET
Category:
MVC
Title:
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01560391
Message ID:
01560397
Views:
48
Craig,

There is nothing too complex in this code. In fact, this code is based on the blog I found

http://dotnetspeak.com/index.php/2012/10/asp-net-mvc-template-and-knockout-js/

So, I just implemented his idea because I liked the idea of lean views. My client form has just a few lines of code instead of many more.

However, one of the properties of my model is a numeric only type. I want to find out a simple way to tell my Editor to use numeric only input.

I can do this by several ways - introducing a new editor for numeric only types sounds to me like the simplest idea. However, if I can make that existing editor "smarter", it will be even better.

I don't see what is so wrong in what I am thinking of.

>I'm with Mike and others on this. And your code is WAY overly complex. Why you're trying to build dictionaries and bind data in this way is beyond me. It's really simple to do this, but I refuse to help because 1) You jump way to deep into things 2) You way over complicate simple stuff 3) You don't know how to debug your own code and get to the root of the issue 4) See #2 5) There are tons of examples on the interwebs if you'd learn to use a search engine 6) See #2
>
>>Hi everybody,
>>
>>I have the following EditorFor in the Shared/ EditorTemplates directory:
>>
>>
>><div class="editor-label">
>>    @Html.Label((ViewData.ModelMetadata.DisplayName??ViewData.ModelMetadata.PropertyName),
>>        new Dictionary<string, object>
>>            {
>>                { "for", ViewData.ModelMetadata.PropertyName }
>>            })
>></div>
>>
>><div class="editor-field">
>>    @Html.TextBox("", (object)Model,
>>        new Dictionary<string, object>
>>            {
>>                { "id", ViewData.ModelMetadata.PropertyName },
>>                { "name", ViewData.ModelMetadata.PropertyName },
>>                { "class", "text-box single-line"},
>>                { "data-bind", "value: " + ViewData.ModelMetadata.PropertyName },
>>            })
>>    @Html.ValidationMessage(ViewData.ModelMetadata.PropertyName,
>>        new Dictionary<string, object>
>>            {
>>                { "data-valmsg-for", ViewData.ModelMetadata.PropertyName }
>>            })
>></div>
>>
>>
>>If I type ViewData. I don't get any intellisense, unfortunately :( I am wondering, is there a way to find the type of my model property in this code and if it's numeric type, I want to use my special numeric only textbox class (and input type = "number" - HTML5).
>>
>>I got this idea http://stackoverflow.com/questions/13984602/how-to-make-entry-field-to-allow-numbers-only-using-ef-and-data-annotations and that's what I was thinking yesterday night also myself, but if I can make this EditorFor smarter, I would not need a UIHint.
>>
>>Do you know if this is a doable idea or I should go with a separate Editor? Also, in case of the later idea, how can I use input type="number" instead of @Html.TextBox
>>
>>?
>>
>>Thanks a lot in advance.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform