User-941767363 posted
Hi, is it possible to "Turn on/turn off" RUNTIME the [Required] attribute of a member of a class?
For example I need to "turn off" the Required of "TemperatureC" in a specific situation (when I click on a specific button).
<div> public class WeatherForecast</div> <div> {</div> <div> public DateTime Date { get; set; }</div> <div>
[Required]</div> <div> public int? TemperatureC { get; set; }</div> <div> </div> <div> public int TemperatureF
=> 32 + (int)(TemperatureC / 0.5556);</div> <div> [Required]</div> <div> [MaxLength(10)]</div> <div>
public string Summary { get; set; }</div> <div> }</div>