I found out the solution, Here i created my custom attribute, [GreaterThan]
[Required(ErrorMessage = "Signal Start Range Field Is Mandatory.")]
[DisplayName("Signal Start Range")]
public string SignalStartRange { get; set; }
[Required(ErrorMessage = "Signal End Range Field Is Mandatory.")]
[DisplayName("Signal End Range")]
[GreaterThan(PropName = "SignalStartRange", ErrorMessage ="End rand should not be lesser than start ragne")]
public string SignalEndRange { get; set; }
public class GreaterThanAttribute: ValidationAttribute
{
public string PropName { get; set; }
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
{
PropertyInfo otherPropertyInfo = validationContext.ObjectType.GetProperty(PropName);
var otherPropertyStringValue = otherPropertyInfo.GetValue(validationContext.ObjectInstance, null).ToString();
if(Convert.ToUInt32(value) < Convert.ToUInt32(otherPropertyStringValue))
{
return new ValidationResult(FormatErrorMessage(validationContext.DisplayName));
}
return null;
}
}