Ejemplo n.º 1
0
 /// <summary>
 /// IsSelected implements the logic of the Selected property of the underlying option elements. As the other
 /// options are relevant in the, this has to be evaluated on the Select elements level
 /// </summary>
 /// <param name="optionElement"></param>
 /// <returns></returns>
 internal bool IsSelected(OptionElement optionElement)
 {
     if (this.MultiValued || Options.Any(o => o.GetAttributeValue("selected") != null))
     {
         return(optionElement.GetAttributeValue("selected") != null);
     }
     else
     {
         return(optionElement.Element == this.Options.First().Element);
     }
 }
Ejemplo n.º 2
0
 internal void MakeSelected(OptionElement optionElement, bool selected)
 {
     if (!selected)
     {
         optionElement.Element.RemoveAttributeCI("selected");
     }
     else
     {
         optionElement.Element.SetAttributeValue(XName.Get("selected"), "selected");
         if (!this.MultiValued)
         {
             foreach (var option in Options)
             {
                 if (option.Element != optionElement.Element)
                 {
                     option.Element.RemoveAttributeCI("selected");
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
 internal static HtmlElement CreateFor(XElement element)
 {
     HtmlElement result;
     switch (element.Name.LocalName.ToLower())
     {
         case "form":
             result = new FormElement(element);
             break;
         case "input":
             string type = element.GetAttribute("type") ?? "";
             switch (type.ToLower())
             {
                 case "radio":
                     result = new RadioInputElement(element);
                     break;
                 case "checkbox":
                     result = new CheckboxInputElement(element);
                     break;
                 case "submit":
                 case "image":
                 case "button":
                     string buttonType = element.GetAttribute("type");
                     result = new ButtonInputElement(element);
                     break;
                 case "file":
                     result = new FileUploadElement(element);
                     break;
                 default:
                     result = new InputElement(element);
                     break;
             }
             break;
         case "textarea":
             result = new TextAreaElement(element);
             break;
         case "select":
             result = new SelectElement(element);
             break;
         case "option":
             result = new OptionElement(element);
             break;
         case "iframe":
         case "frame":
             var src = element.GetAttributeCI("src");
             if (!string.IsNullOrWhiteSpace(src))
             {
                 result = new FrameElement(element);
             }
             else
             {
                 result = default(HtmlElement);
             }
             break;
         case "a":
             result = new AnchorElement(element);
             break;
         case "label":
             result = new LabelElement(element);
             break;
         case "button":
             result = new ButtonInputElement(element);
             break;
         default:
             result = new HtmlElement(element);
             break;
     }
     return result;
 }
Ejemplo n.º 4
0
 internal void MakeSelected(OptionElement optionElement, bool selected)
 {
     if (!selected)
     {
         optionElement.Element.RemoveAttributeCI("selected");
     }
     else
     {
         optionElement.Element.SetAttributeValue(XName.Get("selected"), "selected");
         if (!this.MultiValued)
         {
             foreach (var option in Options)
             {
                 if (option.Element != optionElement.Element)
                 {
                     option.Element.RemoveAttributeCI("selected");
                 }
             }
         }
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// IsSelected implements the logic of the Selected property of the underlying option elements. As the other 
 /// options are relevant in the, this has to be evaluated on the Select elements level
 /// </summary>
 /// <param name="optionElement"></param>
 /// <returns></returns>
 internal bool IsSelected(OptionElement optionElement)
 {
     if (this.MultiValued || Options.Any(o => o.GetAttributeValue("selected") != null))
     {
         return optionElement.GetAttributeValue("selected") != null;
     }
     else
     {
         return optionElement.Element == this.Options.First().Element;
     }
 }