///
/// Mads Haugbø Nissen 2003(c)
/// Objectware AS
/// Norway
///
/// http://weblogs.asp.net/mnissen
///
/// The QueryStringPageViewer provides the same functionality as the regular PageViewerWebPart
/// but allows providing a selection of querystring parameters from the page that hosts this webpart
/// to the page viewed in the QueryStringPageViewer.
///
[DefaultProperty(“ContentLink”),
ToolboxData(“<{0}:QueryStringPageViewer runat=server>”),
XmlRoot(Namespace=”http://www.objectware.no/Lawyer/Sharepoint/Webparts/QueryStringPageViewer“)]
public class QueryStringPageViewer : Microsoft.SharePoint.WebPartPages.WebPart
{
private string _contentLink = “”;
[Browsable(true)]
[Category(“Content”)]
[DefaultValue(“”)]
[WebPartStorage(Storage.Shared)]
[FriendlyName(“The url of the content to show.”)]
[Description(“Supply Querystring params to be passed like this: Page.aspx?Param1&Param2&Param3”)]
public string ContentLink
{
get
{
return this._contentLink;
}
set
{
this._contentLink = value;
}
}
protected string BaseUrl
{
get
{
int endIndex = this.ContentLink.IndexOf(“?”);
if(endIndex != -1)
return this.ContentLink.Substring(0, endIndex + 1);
else
return “”;
}
}
///
/// Render this Web Part to the output parameter specified.
///
/// The HTML writer to write out to
protected override void RenderWebPart(HtmlTextWriter output)
{
string url = this.UrlWithQueryStringGet();
if(url.Length > 0)
{
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.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();
output.RenderEndTag();
}
else
{
Control c = new LiteralControl(string.Format(“To link to content, open the panel and then type a URL in the ContentLink text box with QueryString parameters formatted like this: ‘Page.aspx?Param1&Param2’.”, 1, 129, this.ID));
c.RenderControl(output);
}
}
private ArrayList QueryStringKeysGet()
{
int startIndex = this.ContentLink.IndexOf(“?”);
ArrayList queryStrings = new ArrayList();
if(startIndex > -1 && this.ContentLink.Length > startIndex + 1)
{
string queryStringRaw = this.ContentLink.Substring(startIndex + 1);
if(queryStringRaw.IndexOf(“&”) != -1)
{
string[] tokens = queryStringRaw.Split(new char[]{‘&’});
for(int i = 0; i < tokens.Length; i++)
queryStrings.Add(tokens[i].ToLower());
}
else
{
queryStrings.Add(queryStringRaw.ToLower());
}
}
return queryStrings;
}
protected virtual string UrlWithQueryStringGet()
{
ArrayList queryStringsToPass = this.QueryStringKeysGet();
string url = this.BaseUrl;
for(int i=0; i < Page.Request.QueryString.Count; i++)
{
string queryStringKey = Page.Request.QueryString.Keys[i];
string queryStringValue = Page.Request.QueryString[i];
if(queryStringsToPass.IndexOf(queryStringKey.ToLower()) != -1)
{
url += queryStringKey + “=” + queryStringValue + “&”;
}
}
url = url.TrimEnd(new char[]{‘&’});
return url;
}
}
/// Mads Haugbø Nissen 2003(c)
/// Objectware AS
/// Norway
///
/// http://weblogs.asp.net/mnissen
///
/// The QueryStringPageViewer provides the same functionality as the regular PageViewerWebPart
/// but allows providing a selection of querystring parameters from the page that hosts this webpart
/// to the page viewed in the QueryStringPageViewer.
///
[DefaultProperty(“ContentLink”),
ToolboxData(“<{0}:QueryStringPageViewer runat=server>”),
XmlRoot(Namespace=”http://www.objectware.no/Lawyer/Sharepoint/Webparts/QueryStringPageViewer“)]
public class QueryStringPageViewer : Microsoft.SharePoint.WebPartPages.WebPart
{
private string _contentLink = “”;
[Browsable(true)]
[Category(“Content”)]
[DefaultValue(“”)]
[WebPartStorage(Storage.Shared)]
[FriendlyName(“The url of the content to show.”)]
[Description(“Supply Querystring params to be passed like this: Page.aspx?Param1&Param2&Param3”)]
public string ContentLink
{
get
{
return this._contentLink;
}
set
{
this._contentLink = value;
}
}
protected string BaseUrl
{
get
{
int endIndex = this.ContentLink.IndexOf(“?”);
if(endIndex != -1)
return this.ContentLink.Substring(0, endIndex + 1);
else
return “”;
}
}
///
/// Render this Web Part to the output parameter specified.
///
/// The HTML writer to write out to
protected override void RenderWebPart(HtmlTextWriter output)
{
string url = this.UrlWithQueryStringGet();
if(url.Length > 0)
{
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.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();
output.RenderEndTag();
}
else
{
Control c = new LiteralControl(string.Format(“To link to content, open the panel and then type a URL in the ContentLink text box with QueryString parameters formatted like this: ‘Page.aspx?Param1&Param2’.”, 1, 129, this.ID));
c.RenderControl(output);
}
}
private ArrayList QueryStringKeysGet()
{
int startIndex = this.ContentLink.IndexOf(“?”);
ArrayList queryStrings = new ArrayList();
if(startIndex > -1 && this.ContentLink.Length > startIndex + 1)
{
string queryStringRaw = this.ContentLink.Substring(startIndex + 1);
if(queryStringRaw.IndexOf(“&”) != -1)
{
string[] tokens = queryStringRaw.Split(new char[]{‘&’});
for(int i = 0; i < tokens.Length; i++)
queryStrings.Add(tokens[i].ToLower());
}
else
{
queryStrings.Add(queryStringRaw.ToLower());
}
}
return queryStrings;
}
protected virtual string UrlWithQueryStringGet()
{
ArrayList queryStringsToPass = this.QueryStringKeysGet();
string url = this.BaseUrl;
for(int i=0; i < Page.Request.QueryString.Count; i++)
{
string queryStringKey = Page.Request.QueryString.Keys[i];
string queryStringValue = Page.Request.QueryString[i];
if(queryStringsToPass.IndexOf(queryStringKey.ToLower()) != -1)
{
url += queryStringKey + “=” + queryStringValue + “&”;
}
}
url = url.TrimEnd(new char[]{‘&’});
return url;
}
}
http://schemas.microsoft.com/WebPart/v2” >
Passes querystring parameters to the page in the viewer.”>
Objectware.Lawyer.Sharepoint
Objectware.Lawyer.Sharepoint.WebParts.QueryStringPageViewer>
http://www.objectware.no/Lawyer/Sharepoint/Webparts/QueryStringPageViewer”>/a>>
Passes querystring parameters to the page in the viewer.”>
Objectware.Lawyer.Sharepoint
Objectware.Lawyer.Sharepoint.WebParts.QueryStringPageViewer>