Exemple #1
0
 /// <summary>
 /// Create a select list
 /// </summary>
 /// <param name="value">The selected value for the list</param>
 /// <param name="options">The list of options to add to the select list</param>
 /// <param name="name">Name use for the id and name of the html element</param>
 /// <returns>A TagBuilder class to continue to create the tag by adding attr classes etc.</returns>
 public TagBuilder Select(string name, SelectItem[] options, object value)
 {
     return new TagBuilder("select").options(options, value).IDandName(name);
 }
Exemple #2
0
        /// <summary>
        /// Create a radio list
        /// </summary>
        /// <param name="name">Element Name</param>
        /// <param name="items">Option list</param>
        /// <param name="tabIndex">The tabIndex to assign to the radio item</param>
        /// <returns>A TagBuilder class to continue to create the tag by adding attr classes etc.</returns>
        public TagBuilder RadioList(string name, SelectItem[] items, int tabIndex)
        {

            return RadioList(name, new SelectItemList(items), tabIndex, string.Empty, string.Empty, string.Empty);
        }
Exemple #3
0
 /// <summary>
 /// Create a select list
 /// </summary>
 /// <param name="name">Name of the html element</param>
 /// <param name="id">Element ID</param>
 /// <param name="options">The list of options to add to the select list</param>
 /// <returns>A TagBuilder class to continue to create the tag by adding attr classes etc.</returns>
 public TagBuilder Select(string name, string id, SelectItem[] options)
 {
     return new TagBuilder("select").options(options).Name(name).ID(id);
 }
Exemple #4
0
 /// <summary>
 /// Create a radio list where the value is meant to be a string.
 /// </summary>
 /// <param name="name">Element Name</param>
 /// <param name="value">True or false. These string value will be translated to true: on, yes, true, 1 as needed to identify as true</param>
 /// <param name="items">Option list</param>
 /// <returns>A TagBuilder class to continue to create the tag by adding attr classes etc.</returns>
 public TagBuilder RadioList(string name, string value, SelectItem[] items)
 {
     if (string.IsNullOrEmpty(value) == false)
     {
         foreach (var item in items)
         {
             if (item.Value.ToLower() == value.ToLower())
                 item.Selected = true;
         }
     }
     return RadioList(name, new SelectItemList(items), -1, string.Empty, string.Empty, string.Empty);
 }
Exemple #5
0
 /// <summary>
 /// Create a radio list
 /// </summary>
 /// <param name="name">Element Name</param>
 /// <param name="items">Option list</param>
 /// <returns>A TagBuilder class to continue to create the tag by adding attr classes etc.</returns>
 public TagBuilder RadioList(string name, SelectItem[] items)
 {
     return RadioList(name, new SelectItemList(items), -1, string.Empty, string.Empty, string.Empty);
 }
Exemple #6
0
        /// <summary>
        /// Create a radio list
        /// </summary>
        /// <param name="name">Element Name</param>
        /// <param name="items">Option list</param>
        /// <param name="tabIndex">The tabIndex to assign to the radio item</param>
        /// <returns>A TagBuilder class to continue to create the tag by adding attr classes etc.</returns>
        public TagBuilder BoundRadioList(string name, SelectItem[] items, int tabIndex)
        {
            var parent = new TagBuilder("span").ID(name + "Container");

            var i = 0;
            foreach (var item in items)
            {

                // Add radioItem
                var radioItem = parent.AddChild("span").AddClass("radioItem");

                // Add the radio input
                var radio = radioItem.AddChild("input").Name(name).type("radio").value(item.Value).ID(name + i).bindChecked(name);

                // Set the tabIndex
                if (tabIndex > -1) radio.tabIndex(tabIndex);

                // Add the radio label
                radioItem.AddChild("label").@for(name + i).AddClass("radioLabel").InnerText(item.Text);

                // Make the id unique
                i += 1;
            }

            return parent;
        }
Exemple #7
0
 /// <summary>
 /// Create a radio list
 /// </summary>
 /// <param name="name">Element Name</param>
 /// <param name="items">Option list</param>
 /// <returns>A TagBuilder class to continue to create the tag by adding attr classes etc.</returns>
 public TagBuilder BoundRadioList(string name, SelectItem[] items)
 {
     return BoundRadioList(name, items, -1);
 }
Exemple #8
0
 /// <summary>
 /// Adds a SelectItem
 /// </summary>
 /// <param name="item">SelectItem</param>
 /// <returns>Returns the select item list to aid in the fluid interface</returns>
 public SelectItemList Add(SelectItem item)
 {
     _items.Add(item);
     return this;
 }
Exemple #9
0
 /// <summary>
 /// When creating a select list or a radio list etc. this adds a collection of ListItems as the InnerHtml of the 
 /// tag as option elements. You also specify the value of the selected item in the list.
 /// </summary>
 public TagBuilder options(SelectItem[] items, int value)
 {
     this.value(value);
     _options.AddRange(items);
     _selectedOption = (value == 0) ? "" : value.ToString();
     return this;
     //this.value(value);
     //var val = (value == 0) ? "" : value.ToString();
     //return InnerHtml(GetOptionsString(items, val));
 }
Exemple #10
0
 /// <summary>
 /// When creating a select list or a radio list etc. this adds a collection of ListItems as the InnerHtml of the 
 /// tag as option elements
 /// </summary>
 public TagBuilder options(SelectItem[] items)
 {
     _options.AddRange(items);
     return this;
     //return InnerHtml(GetOptionsString(items, ""));
 }