You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iot/labs/Teacher/Infrastructure/Web/HtmlDataAttribute.cs

26 lines
669 B

using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
namespace System.ComponentModel.DataAnnotations
{
public class HtmlDataAttribute :Attribute,IClientModelValidator
{
public string Key { get; }
public string Value { get; }
public HtmlDataAttribute(string value,string key="data-my-group")
{
Value = value;
Key = key;
}
public void AddValidation(ClientModelValidationContext context)
{
var attributes = context.Attributes;
if (!attributes.ContainsKey(Key))
{
attributes.Add(Key, Value);
}
}
}
}