private static string TextAreaBuilder(HtmlControlHelper helper, string name, string value, int rows, int columns, IDictionary <string, object> attributes) { if (attributes == null) { attributes = new ValueDictionary(); } HtmlElementBuilder htb = new HtmlElementBuilder("textarea"); htb.Attributes.Merge(attributes, true); htb.Attributes.Merge("name", name, true); htb.Attributes.Merge("rows", rows, false); htb.Attributes.Merge("cols", columns, false); htb.InnerText = value ?? String.Empty; return(htb.ToString()); }
public static string RadioButton(this HtmlControlHelper helper, string name, object value) { return(RadioButton(helper, name, value, new ValueDictionary())); }
public static string ListBox(this HtmlControlHelper helper, string name, MultiSelectList list, object attributes) { return(ListBox(helper, name, list, new ValueDictionary(attributes))); }
public static string ListBox(this HtmlControlHelper helper, string name, IEnumerable list, string dataTextField, IDictionary <string, object> attributes) { return(ListBox(helper, name, list, dataTextField, null, null, attributes)); }
public static string ListBox(this HtmlControlHelper helper, string name, IEnumerable list) { return(ListBox(helper, name, list, null, null, null, null)); }
public static string DropDownList(this HtmlControlHelper helper, string name, SelectList list) { return(SelectBuilder(helper, name, list, false, null)); }
public static string DropDownList(this HtmlControlHelper helper, string name, IEnumerable list) { return(DropDownList(helper, name, list, null, null, null, null)); }
public static string TextArea <TModel>(this HtmlControlHelper <TModel> helper, string name, Expression <Func <TModel, string> > value) where TModel : class { return(TextArea(helper, name, value, 2, 20, null)); }
public static string Password(this HtmlControlHelper helper, string name) { return(Password(helper, name, null, new ValueDictionary())); }
public static string TextBox(this HtmlControlHelper helper, string name, object value) { return(TextBox(helper, name, value, new ValueDictionary())); }
public static string Hidden(this HtmlControlHelper helper, string name, IDictionary <string, object> attributes) { return(Hidden(helper, name, null, attributes)); }
public static string RadioButton <TModel>(this HtmlControlHelper <TModel> helper, string name, object value, Expression <Func <TModel, bool> > isChecked) where TModel : class { return(RadioButton(helper, name, value, isChecked, null)); }
public static string RadioButton(this HtmlControlHelper helper, string name, object value, bool isChecked, object attributes) { return(RadioButton(helper, name, value, isChecked, new ValueDictionary(attributes))); }
public static string RadioButton(this HtmlControlHelper helper, string name, object value, IDictionary <string, object> attributes) { return(RadioButton(helper, name, value, false, attributes)); }
public static string TextArea(this HtmlControlHelper helper, string name, string value, int rows, int columns, object attributes) { return(TextArea(helper, name, value, rows, columns, new ValueDictionary(attributes))); }
public static string Password(this HtmlControlHelper helper, string name, object value, object attributes) { return(Password(helper, name, value, new ValueDictionary(attributes))); }
private static string SelectBuilder(HtmlControlHelper helper, string name, MultiSelectList dataSource, bool isMultiple, IDictionary <string, object> attributes) { Precondition.Defined(name, () => Error.ArgumentNull("name")); if (attributes == null) { attributes = new ValueDictionary(); } if (isMultiple) { attributes["multiple"] = "multiple"; } else { attributes.Remove("multiple"); } HtmlElementBuilder outer = new HtmlElementBuilder("select"); outer.Attributes.Merge(attributes, true); outer.Attributes.Merge("name", name, true); if (dataSource != null) { StringBuilder builder = new StringBuilder(); IEnumerable <ListItem> listItems = dataSource.GetListItems(); string[] selectedValues = null; if (helper.DataSource.Keys.Any(k => k.Equals(name, StringComparison.OrdinalIgnoreCase))) { selectedValues = helper.DataSource.GetValue <string>(name, String.Empty) .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); } builder.AppendLine(); foreach (ListItem item in listItems) { if (selectedValues != null) { item.Selected = selectedValues.Any(s => String.Equals(item.Value, s, StringComparison.OrdinalIgnoreCase)); } HtmlElementBuilder inner = new HtmlElementBuilder("option"); inner.InnerText = item.Text; if (item.Value != null) { inner.Attributes.Merge("value", item.Value, true); } if (item.Selected) { inner.Attributes.Merge("selected", "selected"); } builder.AppendLine(inner.ToString()); } outer.InnerHtml = builder.ToString(); } return(outer.ToString()); }
public static string Password(this HtmlControlHelper helper, string name, object value, IDictionary <string, object> attributes) { Precondition.Defined(name, () => Error.ArgumentNull("name")); return(InputBuilder(helper, "password", name, value, attributes)); }
public static string TextArea <TModel>(this HtmlControlHelper <TModel> helper, string name, Expression <Func <TModel, string> > value, object attributes) where TModel : class { return(TextArea(helper, name, value, 2, 20, new ValueDictionary(attributes))); }
public static string Password <TModel>(this HtmlControlHelper <TModel> helper, string name, Expression <Func <TModel, object> > value) where TModel : class { return(Password(helper, name, value, null)); }
public static string DropDownList(this HtmlControlHelper helper, string name, IEnumerable list, IDictionary <string, object> attributes) { return(DropDownList(helper, name, list, null, null, null, attributes)); }
public static string Password <TModel>(this HtmlControlHelper <TModel> helper, string name, Expression <Func <TModel, object> > value, object attributes) where TModel : class { return(Password(helper, name, value, new ValueDictionary(attributes))); }
public static string DropDownList(this HtmlControlHelper helper, string name, SelectList list, IDictionary <string, object> attributes) { return(SelectBuilder(helper, name, list, false, attributes)); }
public static string TextArea(this HtmlControlHelper helper, string name, object attributes) { return(TextArea(helper, name, null, 2, 20, new ValueDictionary(attributes))); }
public static string ListBox(this HtmlControlHelper helper, string name, IEnumerable list, object attributes) { return(ListBox(helper, name, list, null, null, null, new ValueDictionary(attributes))); }
public static string TextArea(this HtmlControlHelper helper, string name, string value) { return(TextArea(helper, name, value, 2, 20, new ValueDictionary())); }
public static string ListBox(this HtmlControlHelper helper, string name, MultiSelectList list) { return(ListBox(helper, name, list, null)); }
public static string TextArea(this HtmlControlHelper helper, string name, string value, IDictionary <string, object> attributes) { return(TextArea(helper, name, value, 2, 20, attributes)); }
public static string ListBox(this HtmlControlHelper helper, string name, MultiSelectList list, IDictionary <string, object> attributes) { return(SelectBuilder(helper, name, list, true, attributes)); }
public static string CheckBox(this HtmlControlHelper helper, string name, object value, IDictionary <string, object> attributes) { Precondition.Defined(name, () => Error.ArgumentNull("name")); return(CheckBox(helper, name, value, false, attributes)); }