private string ParseSelectString(string elementname, bool selected) { string result = string.Empty; if (!selected) { return(result); } HTMLControls hTMLControls = EnumHelper <HTMLControls> .Parse(elementname.ToLower()); switch (hTMLControls) { case HTMLControls.textbox: break; case HTMLControls.checkbox: result = "checked"; break; case HTMLControls.listbox: break; case HTMLControls.radiobutton: break; case HTMLControls.dropdownlist: result = "selected"; break; case HTMLControls.textarea: break; default: break; } return(result); }
private static HtmlControl GetHTMLControl(HTMLControls requiredControl, string tagName = null, string[] classNames = null, string innerText = null, string style = null, string href = null, string src = null, string alt = null, string id = null, string title = null, string type = null, Dictionary <string, string> additionAtt = null) { dynamic control = null; switch (requiredControl) { case HTMLControls.div: { control = new HtmlGenericControl(); control.TagName = "div"; break; } case HTMLControls.anchor: { control = new HtmlAnchor(); control.HRef = href; break; } case HTMLControls.image: { control = new HtmlImage(); control.Src = src; if (!String.IsNullOrEmpty(alt)) { control.Alt = alt; } break; } case HTMLControls.generic: { control = new HtmlGenericControl(); control.TagName = tagName; break; } default: break; } if (classNames != null && classNames.Count() > 0) { control.Attributes["class"] = getClassInfo(classNames); } if (!String.IsNullOrEmpty(innerText)) { control.InnerText = innerText; } if (!String.IsNullOrEmpty(style)) { control.Attributes["style"] = style; } if (!String.IsNullOrEmpty(id)) { control.Attributes["id"] = id; } if (!String.IsNullOrEmpty(title)) { control.Attributes["title"] = title; } if (!String.IsNullOrEmpty(type)) { control.Attributes["type"] = type; } if (additionAtt != null) { if (additionAtt.Count() > 0) { foreach (var item in additionAtt) { control.Attributes[item.Key] = item.Value; } } } return(control); }