Ticket T180499
Visible to All Users

XAF app rendering static html differently to common browsers. (IE, Chrome and Mozilla)

created 10 years ago

I'm displaying html emails in a DetailView and each of the solutions I have tried renders them differently to the original and none are correct.
see "originalEmailScreenShot.png" and "originalEmail.html"

Solution 1:I made use of a ASPxHtmlPropertyEdit - see "Fault rendering in ASPxHtmlPropertyEditor.png" not how the bottom of the page renders across the full with of the control and is not aligned with the rest of the contents.
Solution 2:I pass the html to a staticText control - see "staticText1.png" and "staticText2.png" note how there seem to be additional space between all the items compared to the original. (I also included the controller "staticTextViewController.cs")
Solution 3:I have tried to pass the html in to a iframe but seem unable to escape to single and double quote successfully
        void item_ControlCreated(object sender, EventArgs e)
        {
            IEmailMessageIncoming em = View.CurrentObject as IEmailMessageIncoming;
            string body = em.Description;

StaticTextDetailItem item = (StaticTextDetailItem)sender;

item.Text = string.Format("<iframe src="javascript: '{0}'"></iframe>", body);

}

I would prefer to get solution 2 working if possible.

Thanks in advance

Trentin

Comments (1)
DO DO
Dmitry O. (DevExpress) 10 years ago

    Hello Trentin.

    We cannot find an immediate answer and need additional time to research this scenario. We will get back to you once we have any results. Thank you for your patience.

    Answers approved by DevExpress Support

    created 10 years ago (modified 10 years ago)

    Hello Trentin.

    I recommend you implement a custom View Item to pass html into the iframe tag:

    C#
    public interface IModelHtmlViewItem : IModelViewItem { } [ViewItemAttribute(typeof(IModelHtmlViewItem))] public class HtmlViewItem : ViewItem { private ASPxPanel container; private Panel iframeHolder; private void container_Init(object sender, EventArgs e) { IEmailMessageIncoming em = CurrentObject as IEmailMessageIncoming; if(em != null) { string body = em.Description; container.JSProperties["cpEmailContent"] = body; container.JSProperties["cpIFrameMarkup"] = string.Format("<iframe id = {0}_iframe src = \"javascript: void(0)\" frameborder = 0></iframe>", iframeHolder.ClientID);                 container.ClientSideEvents.Init = string.Format(@"function(s, e) {{                                                                     var iframeHolder = document.getElementById('{0}');                                                                     if(iframeHolder) {{                                                                         iframeHolder.innerHTML = s.cpIFrameMarkup;                                                                     }}                                                                     var iframe = document.getElementById('{0}_iframe');                                                                     var content = s.cpWebPageContent;                                                                     if(iframe) {{                                                                         iframe.contentWindow.document.write(content);                                                                     }}                                                                 }}", iframeHolder.ClientID);             } } protected override object CreateControlCore() { container = new ASPxPanel(); container.ID = "WebPageContainer"; container.Init += container_Init; iframeHolder = new Panel(); iframeHolder.ID = "IFrameHolder"; container.Controls.Add(iframeHolder); return (WebControl)container; } public HtmlViewItem(IModelHtmlViewItem info, Type objectType) : base(objectType, info.Id) { } }

    For more details, refer to the following topic:  How to: Implement a View Item.
    Let me know if you need some additional information.

      Show previous comments (2)

        Thanks for the fix :), the html is displayed correctly.
        Is the a setting for the ASPxPanel's height to grow depending upon the content. This is my current solution but its not ideal.

        protected override object CreateControlCore()
               {
                   container = new ASPxPanel();
                   container.ID = "WebPageContainer";
                   container.Init += container_Init;
                   container.EnableClientSideAPI = true;
                   container.Height = 9999;
                   iframeHolder = new Panel();
                   iframeHolder.Height = 9999;
                   iframeHolder.ID = "IFrameHolder";
                   container.Controls.Add(iframeHolder);
                   return (WebControl)container;
               }

        DO DO
        Dmitry O. (DevExpress) 10 years ago

          Hello Trentin,

          ASPxPanel control renders as the <div> tag, so its size always grows based on the content. You can try to adjust size of the iframe with the following script:

          C#
          container.ClientSideEvents.Init = string.Format(@"function(s, e) {{ var iframeHolder = document.getElementById('{0}'); if(iframeHolder) {{ iframeHolder.innerHTML = s.cpIFrameMarkup; }} var iframe = document.getElementById('{0}_iframe'); var content = s.cpEmailContent; if(iframe) {{ iframe.contentWindow.document.write(content); }} var documentBody = iframe.contentWindow.document.body; var contentHeight = documentBody.scrollHeight; iframe.style.height = contentHeight + 'px'; }}", iframeHolder.ClientID);

            Thanks it works nicely.

            Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

            Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.