2

Here is the class code check there is no DataAnnotation.

 public int Rotate { get; set; }

Here is the its use

@Html.HiddenFor(model => model.Screen.Rotate)

Here its generating html, y its generating validation rules????

<input type="hidden" value="" name="Screen.Rotate" id="Screen_Rotate" data-val-required="The Rotate field is required." data-val-number="The field Rotate must be a number." data-val="true">

Note: If i change int Rotate to string Rotate then it does not generate extra attributes for validations like data-val-required, data-val-number etc.

coure2011
  • 40,286
  • 83
  • 216
  • 349

1 Answers1

6

Non-nullable scalar values such as int and DateTime are always considered as required. string isn't required since strings are nullable. As @Biff said, use int? for a non-required int.

Craig Stuntz
  • 125,891
  • 12
  • 252
  • 273
  • 2
    Please don't create a brand new question covering the same problem as an existing question with no accepted answer. Please update the existing question instead. – Craig Stuntz Feb 07 '11 at 19:01
  • coure06- that completed question just points back to this one – automagic May 13 '11 at 17:01