One of the tasks I had recently was to get not only a web page into a SharePoint page but also pass in parameters from the Query String. Let’s say I am going to create the page at http://localhost/sharepoint/mypage.aspx in a normal way. In order to host a page inside that SharePoint page, we can use a Page Viewer Web Part, but this limits what can be done. Instead, we can create a custom web part to do the work…
1 2 3 4 5 6 7 8 9 10 11 12 13 | public class CustomWebPart : WebPart { public override void Render(HtmlTextWriter writer){ string rawUrl = Context.Request.Url.OriginalString; int index = rawUrl.IndexOf("?"); string query = String.Empty; if(index != -1) query = rawUrl.Substring(index); writer.Write( "<iframe src='http://localhost/sharepoint/myOtherPage.aspx" + query + "' width='100%' height='765px'/>" ); } } |