Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 25064

Web Part With Embedded IFrame

$
0
0

Hi,

I have two questions re embedding an iFrame in a Web Part.

I'm using a server side rendered iFrame, e.g. like the code below.

1) Can anyone suggest a way to pass click events from the iFrame through to the Web Part so the contextual tab will activate when the iFrame is clicked? The tab activates fine when the parent Web Part is clicked.

2) What is the 'correct' way to control the height of the iFrame, statically or better dynamically based on the page height?  

thanks for reading this, any help is appreciated! 

        protected override void Render(HtmlTextWriter writer)
        {

            // MSDN
            string url = "http://msdn.microsoft.com/en-us/";

            string frame = "outputFrame";

            writer.AddStyleAttribute("display", "inline");

            writer.AddAttribute(HtmlTextWriterAttribute.Id, frame);

            writer.AddAttribute(HtmlTextWriterAttribute.Name, frame);

            writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%");

            writer.AddStyleAttribute(HtmlTextWriterStyle.Height, "100%");

            writer.AddAttribute("frameBorder", "0");

            writer.AddAttribute(HtmlTextWriterAttribute.Src, url);

            writer.RenderBeginTag(HtmlTextWriterTag.Iframe);

            writer.RenderEndTag();

            base.Render(writer);

        }


Viewing all articles
Browse latest Browse all 25064

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>