Default value for TextBoxFor in ASP.NET MVC

前端 未结 6 1723
我寻月下人不归
我寻月下人不归 2021-01-13 09:04

In ASP.NET MVC, I wrote below code to give the textbox a initial value:

@Html.TextBoxFor(p => p.WEIGHT, new { tabindex = \"140\", 
                                


        
6条回答
  •  日久生厌
    2021-01-13 09:47

    Maybe this? Untested.

    @Html.TextBoxFor(p => (p.WEIGHT==null ? 0 : p.WEIGHT), new { tabindex = "140", 
          @class = "mustInputText noime  w50", 
          maxlength = "8",  
          rule = "InputOnlyNum" })
    

提交回复
热议问题