/// <summary>
        /// Creates a HtmlSelectTag from a HTMLSelectElementClass.
        /// </summary>
        /// <param name="selectElement"> The HTMLSelectElementClass to convert.</param>
        /// <returns> A HtmlSelectTag</returns>
        private HtmlSelectTag CreateHtmlSelectTag(HTMLSelectElementClass selectElement)
        {
            HtmlSelectTag tag = new HtmlSelectTag();

            tag.Class = selectElement.className;
            tag.Id = selectElement.id;
            if ( selectElement.name != null )
            {
                tag.Name = selectElement.name;
            }
            else
            {
                if ( selectElement.id != null )
                {
                    tag.Name = selectElement.id;
                }
                else
                {
                    tag.Name = selectElement.uniqueID;
                    tag.Id = selectElement.uniqueID;
                }
            }
            // TODO: parse from innerHtml
            // tag.OnClick =
            // tag.Style=currentNode.GetAttribute("style",currentNode.NamespaceURI);
            tag.Title = selectElement.title;

            if ( selectElement.multiple )
            {
                tag.Multiple=true;
            }

            tag.Value = selectElement.value;

            // tag.Options = new HtmlOptionCollection();
            //object noll = null;

            IHTMLElementCollection options = (IHTMLElementCollection)selectElement.children;

            // while ( options.MoveNext() )
            foreach ( object obj in options )
            {
                if ( obj is HTMLOptionElementClass )
                {
                    HTMLOptionElementClass option = (HTMLOptionElementClass)obj;

                    HtmlOptionTag optionTag = new HtmlOptionTag();
                    optionTag.Id = option.id;
                    if ( option.selected )
                    {
                        optionTag.Selected=true;
                    }

                    if ( option.text == null )
                    {
                        optionTag.Text = string.Empty;
                    }
                    else
                    {
                        optionTag.Text = option.text;
                    }

                    if ( option.value == null )
                    {
                        optionTag.Value = string.Empty;
                    }
                    else
                    {
                        optionTag.Value = option.value;
                    }

                    optionTag.Key = "Option " + tag.Options.Length.ToString();
                    tag.AddOptionTag(optionTag);
                }
            }

            return tag;
        }
        private void AddSelectNode(FormEditorNode node,HtmlSelectTag select)
        {
            string label;
            label = "<select ";
            label +=" name="+ select.Name;
            if ( select.Multiple )
            {
                label += " multiple";
            }
            label +="/>";

            formEditor.AddSelect(node,label,select);
        }
        /// <summary>
        /// Adds a Select node.
        /// </summary>
        /// <param name="root"> The root node.</param>
        /// <param name="text"> The node text.</param>
        /// <param name="tag"> The HtmlSelectTag.</param>
        public void AddSelect(FormEditorNode root, string text,HtmlSelectTag tag)
        {
            FormEditorNode node = new FormEditorNode();

            // add it to root node
            root.Nodes.Add(node);

            node.Text=text;
            node.BaseHtmlTag = tag;

            if ( tag.Multiple )
            {
                ListBox lst = new ListBox();
                //lst.HorizontalScrollbar=true;
                //lst.DoubleClick+=new EventHandler(ListBox_DoubleClick);
                lst.Size=new Size(200,30);
                lst.BackColor=Color.WhiteSmoke;
                lst.ForeColor=Color.Blue;
                foreach (HtmlOptionTag opt in tag.Options)
                {
                    lst.Items.Add(opt.Value);
                }
                //lst.Name="lstList";
                lst.SelectionMode=SelectionMode.MultiExtended;
                this.ItemHeight=25;

                node.AddListBoxControl("Values:",lst,new EventHandler(ListBox_DoubleClick),new EventHandler(ListBox_SelectedValueChanged));
            }
            else
            {
                ListBox lst = new ListBox();
                //lst.DropDownStyle=ComboBoxStyle.DropDown;
                lst.Size=new Size(200,30);
                lst.BackColor=Color.WhiteSmoke;
                lst.ForeColor=Color.Blue;
                foreach ( HtmlOptionTag opt in tag.Options)
                {
                    lst.Items.Add(opt.Value);
                }
                //lst.Name="cmbList";
                lst.SelectionMode=SelectionMode.One;
                this.ItemHeight=25;

                node.AddListBoxControl("Values:",lst,new EventHandler(ListBox_DoubleClick),new EventHandler(ListBox_SelectedValueChanged));
            }
        }
 /// <summary>
 /// Adds the select tag post data string.
 /// </summary>
 /// <param name="select"> The select tag.</param>
 /// <param name="list"> The arraylist to append tag.</param>
 public void AddSelectPostData(HtmlSelectTag select, ArrayList list)
 {
     // no Name, so we cant send it to server
     if ( !select.Name.StartsWith("ms__id") )
     {
         string s;
         if  ( select.Multiple )
         {
             foreach ( HtmlOptionTag tag in select.Options )
             {
                 HtmlOptionTag opt = tag;
                 if ( opt.Selected )
                 {
                     s = EncodeDecode.UrlEncode(select.Name) + "=" + EncodeDecode.UrlEncode(opt.Value);
                     //name and value
                     list.Add(s);
                 }
             }
         }
         else
         {
             s = EncodeDecode.UrlEncode(select.Name) + "=" + EncodeDecode.UrlEncode(select.Value);
             //name and value
             list.Add(s);
         }
     }
 }
        /// <summary>
        /// Adds the select tag post data string.
        /// </summary>
        /// <param name="select"> The select tag.</param>
        /// <param name="list"> The arraylist to append tag.</param>
        /// <param name="addEndLine"> The add end line boolean value.</param>
        public void AddSelectPostData(HtmlSelectTag select, ArrayList list, bool addEndLine)
        {
            if ( addEndLine )
            {
                select.Value = AddEndLine(select.Value);
            }

            AddSelectPostData(select, list);
        }
        /// <summary>
        /// Creates a select tag.
        /// </summary>
        /// <param name="currentNode"> The XPathNavigator node.</param>
        /// <returns> A HtmlSelectTag.</returns>
        private HtmlSelectTag CreateSelectTag(XPathNavigator currentNode)
        {
            HtmlSelectTag tag = new HtmlSelectTag();

            tag.Class=currentNode.GetAttribute("class",currentNode.NamespaceURI);
            tag.Id=currentNode.GetAttribute("id",currentNode.NamespaceURI);
            tag.Name=currentNode.GetAttribute("name",currentNode.NamespaceURI);
            tag.OnClick=currentNode.GetAttribute("onclick",currentNode.NamespaceURI);
            tag.Style=currentNode.GetAttribute("style",currentNode.NamespaceURI);
            tag.Title=currentNode.GetAttribute("title",currentNode.NamespaceURI);

            if ( tag.OnClick.Length == 0 )
            {
                tag.OnClick = currentNode.GetAttribute("onClick",currentNode.NamespaceURI);
            }

            if ( currentNode.GetAttribute("multiple",currentNode.NamespaceURI)=="true" )
            {
                tag.Multiple=true;
            }

            tag.Value=currentNode.GetAttribute("value",currentNode.NamespaceURI);

            // fill options nodes
            XPathNodeIterator options = currentNode.SelectChildren(XPathNodeType.Element);

            //tag.Options = new HtmlOptionCollection();

            int i=1;
            while ( options.MoveNext() )
            {
                HtmlOptionTag option = new HtmlOptionTag();
                option.Id=options.Current.GetAttribute("id",options.Current.NamespaceURI);
                if ( options.Current.GetAttribute("selected",options.Current.NamespaceURI)=="true" )
                {
                    option.Selected=true;
                }
                option.Text=options.Current.Value;
                option.Value=options.Current.GetAttribute("value",options.Current.NamespaceURI);

                option.Key = "Option " + i;
                tag.AddOptionTag(option);
                i++;
            }

            return tag;
        }