/// <summary> /// Creates a form from a query string. /// </summary> /// <param name="url"> The complete url.</param> /// <returns> A HtmlFormTag.</returns> private HtmlFormTag CreateFormFromQueryString(Uri url) { string action = url.Scheme + "://" + url.Host + url.AbsolutePath; FormConverter converter = new FormConverter(); PostDataCollection postData = converter.GetPostDataCollection(url.Query.TrimStart('?')); HtmlFormTag formTag = new HtmlFormTag(); formTag.Action = action; formTag.Name = "docform"; formTag.Method = base.WebRequest.RequestType.ToString(); foreach ( string key in postData.Keys ) { ArrayList items = postData[key]; HtmlTagBaseList list = new HtmlTagBaseList(); formTag.Add(key, list); foreach ( string value in items ) { HtmlInputTag hiddenField = new HtmlInputTag(); hiddenField.Type = HtmlInputType.Hidden; hiddenField.Name = key; hiddenField.Value = value.Trim().TrimEnd('\0'); list.Add(hiddenField); } } return formTag; }
/// <summary> /// Creates a HtmlInputTag from a HTMLInputElementClass. /// </summary> /// <param name="inputElement"> The HTMLInputElementClass to convert.</param> /// <returns> A HtmlInputTag.</returns> private HtmlInputTag CreateHtmlInputTag(HTMLInputElementClass inputElement) { HtmlInputTag input = new HtmlInputTag(); input.Checked = [email protected](); input.Class = inputElement.className; input.Id = inputElement.id; input.MaxLength = inputElement.maxLength.ToString(); if ( inputElement.name != null ) { input.Name = inputElement.name; } else { if ( inputElement.id != null ) { input.Name = inputElement.id; } else { input.Name = inputElement.uniqueID; input.Id = inputElement.uniqueID; } } // input.OnClick = currentNode.GetAttribute("onclick",currentNode.NamespaceURI); input.ReadOnly = inputElement.readOnly.ToString(); //input.Style = currentNode.GetAttribute("style",currentNode.NamespaceURI); input.Title = inputElement.title; input.Value = inputElement.value; switch ( inputElement.type ) { case "button": input.Type=HtmlInputType.Button; break; case "checkbox": input.Type=HtmlInputType.Checkbox; break; case "file": input.Type=HtmlInputType.File; break; case "hidden": input.Type=HtmlInputType.Hidden; break; case "image": input.Type=HtmlInputType.Image; break; case "password": input.Type=HtmlInputType.Password; break; case "radio": input.Type=HtmlInputType.Radio; break; case "reset": input.Type=HtmlInputType.Reset; break; case "submit": input.Type=HtmlInputType.Submit; break; case "text": input.Type=HtmlInputType.Text; break; default: input.Type=HtmlInputType.Text; break; } return input; }
private void AddInputNode(FormEditorNode node, HtmlInputTag input) { string label; label = "<input "; label +=" type="+ input.Type; label +=" name="+ input.Name; label +=" value="+ input.Value; label +="/>"; formEditor.AddInput(node,label,input); }
/// <summary> /// Adds a Input node. /// </summary> /// <param name="root"> The root node.</param> /// <param name="text"> The node text.</param> /// <param name="inputTag"> The HtmlInputTag.</param> public void AddInput(FormEditorNode root, string text,HtmlInputTag inputTag) { FormEditorNode node = new FormEditorNode(); // add it to root node root.Nodes.Add(node); node.Text=text; node.BaseHtmlTag = inputTag; TextBox[] textboxes; switch (inputTag.Type) { case HtmlInputType.Button: textboxes = GetTextBoxArray(1); textboxes[0].Name = "txtValue"; textboxes[0].Text = inputTag.Value; node.AddTextControl("Value:",textboxes[0],new EventHandler(TextChangeValue)); break; case HtmlInputType.Checkbox: textboxes = GetTextBoxArray(1); textboxes[0].Name = "txtValue"; textboxes[0].Text = inputTag.Value; node.AddTextControl("Value:",textboxes[0],new EventHandler(TextChangeValue)); break; case HtmlInputType.Text: textboxes = GetTextBoxArray(1); textboxes[0].Name = "txtValue"; textboxes[0].Text = inputTag.Value; node.AddTextControl("Value:",textboxes[0],new EventHandler(TextChangeValue)); break; case HtmlInputType.Submit: textboxes = GetTextBoxArray(1); textboxes[0].Name = "txtValue"; textboxes[0].Text = inputTag.Value; node.AddTextControl("Value:",textboxes[0],new EventHandler(TextChangeValue)); break; case HtmlInputType.Password: textboxes = GetTextBoxArray(1); textboxes[0].Name = "txtValue"; textboxes[0].Text = inputTag.Value; node.AddTextControl("Value:",textboxes[0],new EventHandler(TextChangeValue)); break; default: textboxes = GetTextBoxArray(1); textboxes[0].Name = "txtValue"; textboxes[0].Text = inputTag.Value; node.AddTextControl("Value:",textboxes[0],new EventHandler(TextChangeValue)); break; } }
/// <summary> /// Adds the input post data string. /// </summary> /// <param name="input"> The input tag.</param> /// <param name="list"> The arraylist to append tag.</param> public void AddInputPostData(HtmlInputTag input, ArrayList list) { // no Name, so we cant send it to server if ( !input.Name.StartsWith("ms__id") ) { string s = EncodeDecode.UrlEncode(input.Name) + "=" + EncodeDecode.UrlEncode(input.Value); switch ( input.Type ) { case HtmlInputType.Radio: if ( input.Checked.ToLower() == "true" ) { //name and value list.Add(s); } break; case HtmlInputType.Image: // do nothing break; default: //name and value list.Add(s); break; } } }
/// <summary> /// Adds the input post data string. /// </summary> /// <param name="input"> The input tag.</param> /// <param name="list"> The arraylist to append tag.</param> /// <param name="addEndLine"> The add end line boolean value.</param> public void AddInputPostData(HtmlInputTag input, ArrayList list, bool addEndLine) { if ( addEndLine ) { input.Value = AddEndLine(input.Value); } AddInputPostData(input, list); }
/// <summary> /// Creates a input tag. /// </summary> /// <param name="currentNode"> The XPathNavigator node.</param> /// <returns> A HtmlInputTag.</returns> private HtmlInputTag FillInputTag(XPathNavigator currentNode) { HtmlInputTag input = new HtmlInputTag(); input.Checked=currentNode.GetAttribute("checked",currentNode.NamespaceURI); input.Class=currentNode.GetAttribute("class",currentNode.NamespaceURI); input.Id=currentNode.GetAttribute("id",currentNode.NamespaceURI); input.MaxLength=currentNode.GetAttribute("maxlength",currentNode.NamespaceURI); input.Name=currentNode.GetAttribute("name",currentNode.NamespaceURI); input.OnClick=currentNode.GetAttribute("onclick",currentNode.NamespaceURI); input.ReadOnly=currentNode.GetAttribute("readonly",currentNode.NamespaceURI); input.Style=currentNode.GetAttribute("style",currentNode.NamespaceURI); input.Title=currentNode.GetAttribute("title",currentNode.NamespaceURI); input.Value=currentNode.GetAttribute("value",currentNode.NamespaceURI); if ( input.OnClick.Length == 0 ) { input.OnClick = currentNode.GetAttribute("onClick",currentNode.NamespaceURI); } switch (currentNode.GetAttribute("type",currentNode.NamespaceURI)) { case "button": input.Type=HtmlInputType.Button; break; case "checkbox": input.Type=HtmlInputType.Checkbox; break; case "file": input.Type=HtmlInputType.File; break; case "hidden": input.Type=HtmlInputType.Hidden; break; case "image": input.Type=HtmlInputType.Image; break; case "password": input.Type=HtmlInputType.Password; break; case "radio": input.Type=HtmlInputType.Radio; break; case "reset": input.Type=HtmlInputType.Reset; break; case "submit": input.Type=HtmlInputType.Submit; break; case "text": input.Type=HtmlInputType.Text; break; default: input.Type=HtmlInputType.Text; break; } return input; }