public static MvcHtmlString RadioButtonListFor <TModel, TRadioButtonListValue>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, RadioButtonList <TRadioButtonListValue> > > expression, EnumDisposicaoRadioButtons disposicaoRadioButtons, IDictionary <string, object> htmlAttributes) where TModel : class { var inputName = GetInputName(expression); RadioButtonList <TRadioButtonListValue> radioButtonList = GetValue(htmlHelper, expression); var tableTag = new TagBuilder("table"); tableTag.MergeAttribute("id", inputName); tableTag.MergeAttribute("class", "radio"); if (disposicaoRadioButtons == EnumDisposicaoRadioButtons.Horizontal) { tableTag.InnerHtml += "<tr>"; foreach (var item in radioButtonList.ListItems) { var radioButtonTag = HorizontalRadioButton(htmlHelper, inputName, new SelectListItem { Text = item.Text, Selected = item.Selected, Value = item.Value.ToString() }, htmlAttributes); tableTag.InnerHtml += radioButtonTag; } tableTag.InnerHtml += "</tr>"; } else { foreach (var item in radioButtonList.ListItems) { var radioButtonTag = VerticalRadioButton(htmlHelper, inputName, new SelectListItem { Text = item.Text, Selected = item.Selected, Value = item.Value.ToString() }, htmlAttributes); tableTag.InnerHtml += radioButtonTag; } } return(new MvcHtmlString(tableTag.ToString())); }
public static MvcHtmlString RadioButtonListFor <TModel, TRadioButtonListValue>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, RadioButtonList <TRadioButtonListValue> > > expression, EnumDisposicaoRadioButtons disposicaoRadioButtons) where TModel : class { return(htmlHelper.RadioButtonListFor(expression, disposicaoRadioButtons, null)); }
public static MvcHtmlString RadioButtonListFor <TModel, TRadioButtonListValue>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, RadioButtonList <TRadioButtonListValue> > > expression, EnumDisposicaoRadioButtons disposicaoRadioButtons, object htmlAttributes) where TModel : class { return(htmlHelper.RadioButtonListFor(expression, disposicaoRadioButtons, new RouteValueDictionary(htmlAttributes))); }