using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using Microsoft.SharePoint; using Microsoft.SharePoint.WebControls; using Microsoft.SharePoint.WebPartPages; using System.ComponentModel; using System.Collections.Specialized; namespace QueryStringPageViewer { public class QSPVWP : Microsoft.SharePoint.WebPartPages.WebPart { //Set custom attribute to allow user to specify Base URL in Tool Pane private string _baseURL = ""; [WebBrowsable(true), Personalizable(PersonalizationScope.Shared), Category("Base URL Settings"), WebDisplayName("Base URL"), WebDescription("Supply the Base URL for the page viewer query string web part.")] public string baseURL { get { return this._baseURL; } set { this._baseURL = value; } } protected override void RenderWebPart(HtmlTextWriter output) { NameValueCollection queryString = Page.Request.QueryString; string URL = this.baseURL; int paramCount = 0; if (queryString.Count > 0) { // Set up URL as having a Query String URL += "?"; // Loop through QueryString collection and add all name/value pairs to 'URL' foreach (string qsName in queryString) { // Add name/value pair for current key to the URL URL += qsName + "=" + queryString[qsName]; // Add ampersand for all but the last query string parameter paramCount++; if (paramCount < queryString.Count) URL += "&"; } } string name = "QueryStringPageViewer_" + this.UniqueID; output.AddAttribute(HtmlTextWriterAttribute.Id, name, false); output.AddAttribute(HtmlTextWriterAttribute.Name, name, false); output.AddAttribute(HtmlTextWriterAttribute.Width, "100%", false); output.AddAttribute(HtmlTextWriterAttribute.Height, "100%", false); output.AddAttribute(HtmlTextWriterAttribute.Src, URL, false); output.AddAttribute("ddf_src", URL, false); output.AddAttribute("frameBorder", "0", false); output.RenderBeginTag(HtmlTextWriterTag.Iframe); output.RenderBeginTag(HtmlTextWriterTag.Div); output.Write("IFrames not supported by this browser"); output.RenderEndTag(); //Div output.RenderEndTag(); //Iframe } } }