我有一个包含 int 数据字段的文本框。页面加载时,默认显示 0。以下是显示文本框的代码:
<%:Html.TextBoxFor(model => model.Ssn, htmlAttributes: new { @class = "txtBox txtBoxMediumSmall" })%>
其中 model.Ssn 是一个int。
为什么不为空?应该怎么做才能让它变成空白?
如果需要更多信息,请告诉我。
最佳答案
你可以这样做
public class MyModel
{
//Nullable integer
public int? Ssn {get; set;} //this should be null by default
public int SSN {get; set; } //this should be 0 by default
}
关于c# - HTML 文本框将 int 数据字段的默认值显示为 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12650466/