Esempio n. 1
0
        private void NormalizeAspNetForms(XhtmlDocument xhtmlDocument)
        {
            // If current control is inside <form id="" runat="server"> tag all <asp:forms> tags will be removed from placeholder

            bool isInsideAspNetForm = false;

            var ansestor = this.Parent;

            while (ansestor != null)
            {
                if (ansestor is HtmlForm)
                {
                    isInsideAspNetForm = true;
                    break;
                }

                ansestor = ansestor.Parent;
            }

            if (!isInsideAspNetForm)
            {
                return;
            }

            List <XElement> aspNetFormElements = xhtmlDocument.Descendants(Namespaces.AspNetControls + "form").Reverse().ToList();

            foreach (XElement aspNetFormElement in aspNetFormElements)
            {
                aspNetFormElement.ReplaceWith(aspNetFormElement.Nodes());
            }
        }
Esempio n. 2
0
        /// <exclude />
        public static void ResolveRelativePaths(XhtmlDocument xhtmlDocument)
        {
            IEnumerable <XElement>   xhtmlElements  = xhtmlDocument.Descendants().Where(f => f.Name.Namespace == Namespaces.Xhtml);
            IEnumerable <XAttribute> pathAttributes = xhtmlElements.Attributes().Where(f => f.Name.LocalName == "src" || f.Name.LocalName == "href" || f.Name.LocalName == "action");

            string applicationVirtualPath = UrlUtils.PublicRootPath;

            List <XAttribute> relativePathAttributes = pathAttributes.Where(f => f.Value.StartsWith("~/") || f.Value.StartsWith("%7E/")).ToList();

            foreach (XAttribute relativePathAttribute in relativePathAttributes)
            {
                int tildePrefixLength = (relativePathAttribute.Value.StartsWith("~") ? 1 : 3);
                relativePathAttribute.Value = applicationVirtualPath + relativePathAttribute.Value.Substring(tildePrefixLength);
            }

            if (applicationVirtualPath.Length > 1)
            {
                List <XAttribute> hardRootedPathAttributes = pathAttributes.Where(f => f.Value.StartsWith("/Renderers/")).ToList();

                foreach (XAttribute hardRootedPathAttribute in hardRootedPathAttributes)
                {
                    hardRootedPathAttribute.Value = applicationVirtualPath + hardRootedPathAttribute.Value;
                }
            }
        }
Esempio n. 3
0
 public void MovePageNumbers()
 {
     foreach (var span in XhtmlDocument.Descendants(XhtmlNs + "span").Where(IsPageNumberElement))
     {
         Utils.TrimWhiteSpace(span);
         Utils.AddPageName(span);
         MovePageNumber(span);
     }
 }