c# - Have Required Attribute apply to property in one view and not another? -


say have class called test , have create , edit view. class incredibly simple

public class test {     [required]     public string str { get; set; } } 

is possible remove required attribute when user editing object?

viewmodels there this. 1 create , 1 edit.

you should use viewmodel this, need view specific models here :

public class createtestviewmodel {     [required]     public string str { get; set; } } 

and:

public class edittestviewmodel {     public string str { get; set; } } 

you might want read what viewmodel in mvc , how use viewmodel in mvc


Comments

Popular posts from this blog

'hasOwnProperty' in javascript -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -

How to understand 2 main() functions after using uftrace to profile the C++ program? -