Data annotations MVC3 Required attribute

前端 未结 2 1929
暖寄归人
暖寄归人 2021-01-19 22:07

I have the Model (User) below, I use it to add new users and to update existing users. When I\'m adding a new user it\'s required to enter the user name and the password, a

2条回答
  •  轮回少年
    2021-01-19 22:49

    I normally specify in my BaseViewModel which elements to hide, then use jQuery to hide them. It can mess with your layout though, if you use more 'fancy' layouts than my usual top to bottom column-based layouts. Hide form-group for each element to be hidden, and the elements below it just shift upwards.

    My main line of work is LOB intranet apps, so I skip all the fancy most of the time.

提交回复
热议问题