Skip to content

Instantly share code, notes, and snippets.

@jasonhjohnson
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonhjohnson/19c53cf19a10e434d46d to your computer and use it in GitHub Desktop.
Save jasonhjohnson/19c53cf19a10e434d46d to your computer and use it in GitHub Desktop.
Expressive Annotations Issue
@Html.EditorFor(x => x.NewRenovationConstruction, new { options = yesNoListItems, @class = "radio-inline", @data_bind = "" })
[Serializable]
public class PropertyViewModel : FormGroupViewModel
{
/// <summary>
/// Gets or sets the new renovation construction.
/// </summary>
/// <value>
/// The new renovation construction.
/// </value>
[UIHint("RadioButtonList")]
[RequiredIf("RenewalFormGroupStatusId == 3", ErrorMessage = "Please provide an answer before completing the application.")]
public string NewRenovationConstruction { get; set; }
}
@model string
@using System.Collections
@using System.Web.Mvc;
@{
var list = (List<SelectListItem>)ViewData["options"];
}
@foreach (var item in list)
{
var cssClass = ViewData["class"] == null ? "radio-inline" : ViewData["class"];
var value = ViewData["value"];
<div class="@cssClass">
<label>
@{
var radioId = ViewData.TemplateInfo.GetFullHtmlFieldId(item.Value);
var checkedClass = (item.Value == Model ? "checked" : string.Empty);
var required = (ViewContext.ViewData.ModelMetadata.IsRequired ? "required" : string.Empty);
<input type="radio"
id="@radioId"
name="@ViewData.TemplateInfo.HtmlFieldPrefix"
value="@item.Value"
data-bind="@ViewData["data_bind"]"
onclick="@ViewData["onclick"]"
@checkedClass
@required />
}
@item.Text
</label>
</div>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment