Hi,
I m trying to do a simple validation on textbox, its a required field and cannot be empty. Initially value will be empty so when user do not enter any value into the field and directly clicks Save button then valitaion is not triggered. It works fine when user types something and then deletes the value from it then it works perfectly and shows the validation error message. Is there anyway to do validation check after user clicks save button.
[Display(Name = "Sometext", Description = "Some text")]
[Required(ErrorMessage = "Required Field")]
public string SomeText
{
get
{
return _someText;
}
set
{
if (_someText== value &&
value != string.Empty)
{
return;
}
Validate(value, "someText");//This calls Validator.ValidateProperty method
_someText= value;
FirePropertyChanged("someText");
}
}
Please suggest!
Thanks in advance Sai