Exemplo n.º 1
0
        private static void RestoreData(IDomElement e, CQ csQueryContext, HttpContext httpContext = null)
        {
            var    context = httpContext ?? HttpContext.Current;
            string value   = context.Request.Form[e["name"]];

            if (value != null)
            {
                switch (e.NodeName)
                {
                case "textarea":
                    e.InnerText = value;
                    break;

                case "input":
                    switch (e["type"])
                    {
                    case "checkbox":
                    case "radio":
                        if (value != null)
                        {
                            e.SetAttribute("checked");
                        }
                        else
                        {
                            e.RemoveAttribute("checked");
                        }
                        break;

                    case "hidden":
                    case "text":
                    case "password":
                    case "button":
                    case "submit":
                    case "image":
                        e.SetAttribute("value", value);
                        break;

                    case "file":
                        break;

                    default:
                        e.SetAttribute("value", value);
                        break;
                    }
                    break;

                case "select":
                    csQueryContext[e].Val(value);
                    break;

                default:
                    // just use value
                    csQueryContext[e].Val(value);
                    break;
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Restore "value" to a single element.
        /// </summary>
        ///
        /// <exception cref="InvalidOperationException">
        /// Thrown when the requested operation is invalid.
        /// </exception>
        ///
        /// <param name="element">
        /// The element to restore a value to
        /// </param>
        /// <param name="csQueryContext">
        /// The context to which this element belongs
        /// </param>
        /// <param name="value">
        /// The value to restore
        /// </param>

        private static void RestoreData(IDomElement element, CQ csQueryContext, string value)
        {
            switch (element.NodeNameID)
            {
            case HtmlData.tagTEXTAREA:
                element.TextContent = value;
                break;

            case HtmlData.tagINPUT:
                switch (element["type"])
                {
                case "checkbox":
                case "radio":
                    if (value != null &&
                        ((element.Value ?? "on") == value))
                    {
                        element.SetAttribute("checked");
                    }
                    else
                    {
                        element.RemoveAttribute("checked");
                    }
                    break;

                case "hidden":
                case "text":
                case "password":
                case "button":
                case "submit":
                case "image":
                    element.SetAttribute("value", value);
                    break;

                case "file":
                    break;

                default:
                    element.SetAttribute("value", value);
                    break;
                }
                break;

            case HtmlData.tagSELECT:
            case HtmlData.tagBUTTON:
                csQueryContext[element].Val(value);
                break;

            default:
                throw new InvalidOperationException(String.Format("An unknown element type was found while restoring post data: '{0}'", element.NodeName));
            }
        }
Exemplo n.º 3
0
        public virtual void SetAttributeValue(string attributeName, string xmlValue, bool isIdAttribute)
        {
            string oldValue = GetAttributeValue(attributeName);

            if (isIdAttribute)
            {
                _domElement.SetIdAttribute(attributeName, xmlValue);
            }
            else
            {
                _domElement.SetAttribute(attributeName, xmlValue);
            }

            IAttribute attribute = _elementType.GetAttribute(attributeName);

            if (attribute != null)
            {
                ((AttributeImpl)attribute).UpdateIncomingReferences(this, xmlValue, oldValue);
            }
        }
Exemplo n.º 4
0
        private void BuildUI()
        {
            _processViewerArea = DomManager.Document.GetElementById("process-viewer-area");
            _mainTable = DomManager.CreateElement("table");
            _mainTable.SetAttribute("cellspacing", "2");
            _mainTable.SetAttribute("cellpadding", "2");

            IDomElement tr = DomManager.CreateElement("tr");
            tr.SetAttribute("valign", "top");

            IDomElement td = DomManager.CreateElement("td");
            IDomElement sipTableHeader = DomManager.CreateElement("span");
            sipTableHeader.InnerHtml = "Processes:<br />----------------------------------------<br />";
            td.AppendChild(sipTableHeader);
            IDomElement sipTable = BuildSIPTable();
            _sipTableBody = DomManager.CreateElement("tbody");
            sipTable.AppendChild(_sipTableBody);
            td.AppendChild(sipTable);
            tr.AppendChild(td);

            td = DomManager.CreateElement("td");
            IDomElement threadTableHeader = DomManager.CreateElement("span");
            threadTableHeader.InnerHtml = "Threads:<br />---------------------------------------------------------------<br />";
            td.AppendChild(threadTableHeader);
            IDomElement threadTable = BuildThreadTable();
            _threadTableBody = DomManager.CreateElement("tbody");
            threadTable.AppendChild(_threadTableBody);
            td.AppendChild(threadTable);
            tr.AppendChild(td);

            _mainTable.AppendChild(tr);

            _processViewerArea.AppendChild(DomManager.CreateElement("br"));

            _lastUpdatedElement = DomManager.CreateElement("span");
            _processViewerArea.AppendChild(_lastUpdatedElement);

            _processViewerArea.AppendChild(DomManager.CreateElement("br"));

            _processViewerArea.AppendChild(_mainTable);
        }