Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Test of the model type
Message
 
 
General information
Forum:
ASP.NET
Category:
MVC
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01560569
Message ID:
01560612
Views:
41
>Don't understand the question. If the type is Int16 then it's Int16 - where does decimal come into it ?
>
I solved this way:
 @if (ViewData.ModelMetadata.ModelType.IsNumeric())
   {
    <input type="number" id=@ViewData.ModelMetadata.PropertyName name=@ViewData.ModelMetadata.PropertyName class="numericOnly" value=@Model  />
   }
    else
    {
     @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 },
            })
    }
where IsNumeric was an extension method based on the last message in this thread
http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/66a7dc8d-f276-4d45-8da4-f8d9857db52c/
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