Monday, May 7, 2012

ASP.NET MVC Authentication - Customizing Authentication and Authorization The Right Way

ASP.NET MVC: Adding aria-required attribute for required fields

     var attributes = new RouteValueDictionary
                             { "class", "text-box single-line"}
     if (ViewContext.ViewData.ModelMetadata.IsRequired)
         attributes.Add("aria-required", "true");
@Html.TextBox("", ViewContext.ViewData.TemplateInfo.FormattedModelValue, attributes)

What is aria-required?

It is a HTML property to indicate if user input field is required. This property is for Accessible Rich Internet Applications
<input name="ariaexample" id="example" aria-required="true" aria-label="Test"/>