如何在MVC中查看比较验证

时间:2014-07-16 10:09:37

标签: asp.net-mvc-4

在MVC 4中需要像CompareValidator一样在View中查看From To To Values To To Value是否大于From Value?

型号:

[Required(ErrorMessage = "Please Enter From")]
public int FROM_RECORDVALUE { get; set; }

[Required(ErrorMessage = "Please Enter To")]
public int TO_RECORDVALUE { get; set; }

查看:

<div class="row">
   <div class="col-md-2">
      <div class="form-group">
         <label class="defaultlable">
            @Model.getPickListMaster().getPickListHeaderName("RECORDVALUE") From
         </label>
          @Html.TextBoxFor(model => model.FROM_RECORDVALUE, new { @class = "form-control", @maxlength = @Model.getPickListMaster().MAX_LENGTH })
      </div>
   </div>
   <div class="col-md-2">
        <div class="form-group">
           <label class="defaultlable">
          @Model.getPickListMaster().getPickListHeaderName("RECORDVALUE") To
           </label>
         @Html.TextBoxFor(model => model.TO_RECORDVALUE,new { @class = "form-control", @maxlength = @Model.getPickListMaster().MAX_LENGTH})
        </div>
   </div>
</div>

我怎样才能实现这一目标?请给我一些建议。

0 个答案:

没有答案