Click here to Skip to main content
15,904,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I am surprised with the behaviour of the MVC. I have a model say A

C#
public int requiredField{get;set;}
public int? notRequiredField{get;set;}


MVC validating requiredField field which is good but why validating notRequiredField field which is not either marked as [Required] or any other tag.

The second thing is, I have used int? in the same application on other screens and found no issue with that but on one screen it is making issue.

is it a bug of MVC or my own?
Posted
Comments
♥…ЯҠ…♥ 13-Nov-13 1:31am    
1)Could you brief, what validation is done on notRequiredField? have you mentioned any condition in view?
2) Update your question with what issue you are facing while using int? in your application?
Faisalabadians 13-Nov-13 1:46am    
I have mentioned that it is validating int?, I have not validations for it in view or in model or in controller. The message it is adding is "the notRequiredField is required"

1 solution

Hi Faisalabadians,

Try using Nullable<int> instead of int?
This could solve your one issue I believe.

Regards,
RK
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900