Beispiel #1
0
        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()));
        }
Beispiel #2
0
 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));
 }
Beispiel #3
0
 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)));
 }