Пример #1
0
        /*==================================================== */


        private static MvcHtmlString staticControlHelper(HtmlHelper htmlHelper, ModelMetadata metadata, string name, IEnumerable <SelectListItem> selectList, IDictionary <string, object> htmlAttributes)
        {
            var list = HelperUtils.MarkSelectList(htmlHelper, metadata, name, selectList, false);

            foreach (SelectListItem item in list)
            {
                if (!item.Selected)
                {
                    continue;
                }
                return(htmlHelper.BsStaticControl(name, item.Value, item.Text, htmlAttributes));
            }

            htmlAttributes["editable"] = false;
            return(htmlHelper.BsTextBox(name, null, htmlAttributes));
        }
        private static MvcHtmlString staticControlHelper(HtmlHelper htmlHelper, ModelMetadata metadata, string name, IEnumerable <SelectListItem> selectList, string type, IDictionary <string, object> htmlAttributes)
        {
            string fullName = htmlHelper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(name);
            var    list     = HelperUtils.MarkSelectList(htmlHelper, metadata, name, selectList, type == "checkbox");

            var sb = new StringBuilder();

            foreach (SelectListItem item in list)
            {
                if (!item.Selected)
                {
                    continue;
                }
                sb.AppendLine(generateHtml(fullName, item.Value, item.Text, htmlAttributes));
            }

            return(new MvcHtmlString(sb.ToString()));
        }