Current filter:
                                You should refresh the page.
                                  • 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  
                                • Dmitry O. (DevExpress) 12.01.2014

                                  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.

                                1 Solution

                                Creation Date Importance Sort by
                                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.






                                • Trentin Barnard 12.03.2014

                                  Dmitry, I implemented your example and now I'm getting "undefined" appearing in the HtmlViewItem that I have placed on the DetailView.

                                  Please advise

                                • Dmitry O. (DevExpress) 12.03.2014
                                  Hello Trentin.

                                  Sorry for the mistake.

                                  Please replace the string 
                                  var content = s.cpWebPageContent;
                                  with
                                  var content = s.cpEmailContent;


                                • Trentin Barnard 12.05.2014

                                  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;
                                         }

                                • Dmitry O. (DevExpress) 12.08.2014

                                  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);
                                • Trentin Barnard 12.08.2014

                                  Thanks it works nicely.