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

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -