示例#1
0
        /// <summary>
        /// Gets the designable html.
        /// </summary>
        /// <description>
        /// Generates HTML string to be displayed in the RootDesignerView's WebView.
        /// It contains the designer context in the <head> tag and the init params
        /// in the beginning of the <body> tag.
        /// Also all the ASP.NET and HTML controls are rendered with their HTML representations
        /// to be displayed the way they're going to look to the user.
        /// </description>
        /// <returns>
        /// The designable html string.
        /// </returns>
        public string GetDesignableHtml()
        {
            var           parsedDoc = document.Parse() as AspNetParsedDocument;
            StringBuilder sb        = new StringBuilder();

            SerializeNode(parsedDoc.XDocument.RootElement, sb);
            return(sb.ToString());
        }
示例#2
0
        /// <summary>
        /// Removes a control tag from the source code editor
        /// </summary>
        /// <param name='id'>
        /// Identifier of the control.
        /// </param>
        public void RemoveControlTag(string id)
        {
            if (id == null)
            {
                throw new ArgumentNullException("Cannot find component by an empty string");
            }

            IComponent comp = host.GetComponent(id);

            if (comp == null)
            {
                throw new InvalidOperationException("Component with that name doesn't exists: " + id);
            }

            XDocument doc = document.Parse().XDocument;
            XElement  tag = GetControlTag(doc.RootElement, id);

            if (tag == null)
            {
                throw new InvalidOperationException("The the tag for the component was not found. ID: " + id);
            }

            DomRegion region;

            if (tag.IsSelfClosing)
            {
                region = tag.Region;
            }
            else if (tag.IsClosed)
            {
                region = new DomRegion(tag.Region.Begin, tag.ClosingTag.Region.End);
            }
            else
            {
                throw new InvalidOperationException("The tag has no closing tag. It cannot be removed");
            }

            document.RemoveText(region);
        }