I am using the default asp.net MVC 2 syntax to construct TextBox\'s which are integer or decimal for my asp.net MVC web app:
<%: Html.TextBoxFor(model =&g
I think @jfar's answer points in the right direction but the Int32.ascx should be this
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%
string displayText;
if (Model == 0)
{
displayText = "";
}
else
{
displayText = Model.ToString();
}
%>
<%= Html.TextBox("", displayText)%>
or updated answer using Razor (/Shared/EditorTemplates/Int32.cshtml)
@model Int32
@{
string text = Model == 0 ? "" : Model.ToString();
}
@Html.TextBox("", text)