asp.net mvc - How i can use two optional object in c# when one of them is required? -
After
I have found information on the page through the query string and I validate them through the data annotation feature.
On the page I found PID or EID. In each of them, one of them is always one of them, how can I validate them in MVC.
Can anyone tell me that I can do this in C # asp.net MVC via data annotation.
Set {eId = value; PID = value; }} Public string EID {get; Set; } If I understand you correctly, the situation is that you Allways Either a PID set or EID is needed - one of them can be empty / empty, but never both. And you want to do it with any type of data connection instead of any other kind of recognition. I do not know if it is possible what is there but I doubt it. But you can apply your own (as Phil shows in the great blog post): I want this because you want to validate your Id / PID in an Eid-class With the need to remove this work seems to be done for your annotated field. There is another way to apply -Interface (see blog post) Here is an example for your type and lastly on MSDN: Public String PID {Received;
Class MyClass : IValidatableObject {public string id {get; Set;} public string pid {find; Set;} Public IEnumerable & LT; ValidationResult & gt; ValidationContext VC {if (string.IsNullOrEmpty (Eid) & amp; String.IsNullOrEmpty (PID)) returns the new ValidationResult ("Eid or PID should be set up"; New [] {"Id", "pid"}); }}
Comments
Post a Comment