<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The Mack Page &#187; Development</title>
	<atom:link href="http://www.themackpage.com/category/sharepoint/dev/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.themackpage.com</link>
	<description>Emancipate yourself from mental slavery; none but ourselves can free our minds.  - Nesta</description>
	<lastBuildDate>Mon, 30 Aug 2010 21:01:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using the SharePoint 2010 Dialog Platform with Forms Services</title>
		<link>http://www.themackpage.com/2010/05/06/using-the-sharepoint-2010-dialog-platform-with-forms-services/</link>
		<comments>http://www.themackpage.com/2010/05/06/using-the-sharepoint-2010-dialog-platform-with-forms-services/#comments</comments>
		<pubDate>Thu, 06 May 2010 16:59:14 +0000</pubDate>
		<dc:creator>Joe Mack</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Knowledge Management]]></category>
		<category><![CDATA[SharePoint]]></category>

		<guid isPermaLink="false">http://www.themackpage.com/2010/05/06/using-the-sharepoint-2010-dialog-platform-with-forms-services/</guid>
		<description><![CDATA[First things first, thanks to Jomit for his Dialog Platform post, which served as the basis for my work herein.
So, I recently had occasion to open up a browser-based Forms Services form from outside of the site collection where the template and the "Save Location" both reside…you know, kind of like one of those completely [...]]]></description>
			<content:encoded><![CDATA[<p>First things first, thanks to Jomit for his <a href="http://jomit.blogspot.com/2009/12/dialog-platform-in-sharepoint-2010-how.html" target="_blank">Dialog Platform post</a>, which served as the basis for my work herein.</p>
<p>So, I recently had occasion to open up a browser-based Forms Services form from outside of the site collection where the template and the "Save Location" both reside…you know, kind of like one of those completely unplanned "Real World Scenarios" that we are always hearing about.</p>
<p>Anyway, anyone that has opened up a Forms Services form in the browser has noticed the extremely long URL that is necessary.  For the uninitiated, here is a very quick synopsis of the various portions of the URL.</p>
<ul>
<li>
<div><strong>Base URL.</strong> Forms Services forms are processed by an ASP.NET page located in the layouts folder.  This is the base URL and it looks like this:</div>
<ul>
<li>http://&lt;&lt;URL to your site&gt;&gt;/_layouts/FormServer.aspx</li>
</ul>
</li>
<li>
<div><strong>Query String.</strong> There are various query string parameters that you may or may not have, depending on your situation.</div>
<ul>
<li>
<div><strong>XsnLocation.</strong> This is the location of your Form Template, and it looks something like what appears below.  If you click on the "New" button in a document library configured to use the form, this parameter is NOT encoded, although the others are…it's probably a good idea for you to encode all of them if you are building your own long-ass URL from scratch.  For the sanity of anyone reading, I am not going to show encoded stuff here.  If you would like a quick and easy way to encode/decode stuff, <a href="http://meyerweb.com/eric/tools/dencoder/" target="_blank">here is a good one</a>.</div>
<ul>
<li>XsnLocation=http://&lt;&lt;site&gt;&gt;/Form Templates/Template Name.xsn</li>
</ul>
</li>
<li>
<div><strong>Save Location.</strong> This is usually optional, as the form will just submit to the Document Library specified in the form template if this parameter is not there.  Here is what it normally looks like:</div>
<ul>
<li>SaveLocation=http://&lt;&lt;site&gt;&gt;/Documents</li>
</ul>
</li>
<li>
<div><strong>Source.</strong> This is the page you want to bring up after the user is done with the form…and is the source of the challenge I had that started this whole darn thing.  Basically, if you try to pass a Source parameter that is from a different site collection, Forms Services will treat you like a pigeon treats a statue.  Here is what this parameter looks like:</div>
<ul>
<li>Source=http://&lt;&lt;site&gt;&gt;/Pages/Success.aspx</li>
</ul>
</li>
<li>
<div><strong>DefaultItemOpen.</strong> This parameter is used to force the form to open in a browser.  If it is set to something other than '1' or not present, the form will try to open in InfoPath.  Here is what the "open in browser" option looks like:</div>
<ul>
<li>DefaultItemOpen=1</li>
</ul>
</li>
</ul>
</li>
<li>
<div><strong>The Whole Damn Thing.</strong> So, if you put all that stuff together, it looks something like this:</div>
<ul>
<li>http://docs.company.com/sites/active/_layouts/FormServer.aspx?XsnLocation=http://docs.company.com/sites/active/Form Templates/Template Name.xsn&amp;SaveLocation=http://docs.company.com/sites/active/Documents&amp;Source=http://docs.company.com/sites/active/Documents/Forms/AllItems.aspx&amp;DefaultItemOpen=1</li>
</ul>
</li>
</ul>
<p>So, I am not sure if you caught on to the main issue reading through all that junk, but here it is in a nutshell.  If you try to pass in a "Source" parameter that is from a different site collection than the one where the template is located, Forms Services will barf.  That kind of puts on damper on my "Real World" scenario of having the users access a centralized landing page / application, while exhibiting a higher level of control over the document processing center where the forms are going to be filled out.</p>
<p>I know what some of you might be thinking – just use a new window/tab.  The problem with that is that not everyone likes popups, plus, sometimes you end up with a useless popup sitting there just displaying "The form has been closed" in the middle of the screen.  Besides, popups are just so Web 1.0. Modal windows, that's wave of the future, man!</p>
<p>For those of you that have seen SharePoint 2010 in action, you know Microsoft has gotten behind the whole modal window thing as well.  In fact, if you have access to a SharePoint 2010 box, go ahead and type in the URL to the Upload form of one of your document libraries (http://&lt;&lt;site&gt;&gt;/Documents/Forms/Upload.aspx).  SharePoint will get the standard Upload page from the _layouts folder, and it pretty much looks like a normal SharePoint page, right?  Now, add in a query string parameter so it looks like this (http://&lt;&lt;site&gt;&gt;/Documents/Forms/Upload.aspx?IsDlg=1).  See that?  That form is damn sure ready for a modal dialog, huh?  In fact, it is the standard way that Microsoft allows users to upload documents to a library, by putting the Upload form in a modal window and using the IsDlg parameter to keep all the extraneous stuff from showing up.</p>
<p>Well, that's not the only place where Microsoft has bought into this whole modal window thing.  As it turns out, there is a JavaScript method set up for this that comes along with the ECMAScript Class Library that you can use from just about any SharePoint page.  Check out Jomit's post that I referenced above for a little more detail and the links to learn more about the method and the ECMA library.</p>
<p>Since the FormsServer.aspx page doesn't even recognize the IsDlg parameter, I didn't even need it.  So, armed with everyone's favorite way to hack a SharePoint page (the Content Editor Web Part), I set out to get my InfoPath form to open up in a modal window.  Here is the code that got it to work:</p>
<p style="margin-left: 36pt"><strong><em>&lt;script type="text/javascript"&gt;<br />
</em></strong></p>
<p style="margin-left: 36pt"><strong><em> //Handle the DialogCallback callback<br />
</em></strong></p>
<p style="margin-left: 36pt"><strong><em> function DialogCallback(dialogResult, returnValue)<br />
</em></strong></p>
<p style="margin-left: 36pt"><strong><em> {<br />
</em></strong></p>
<p style="margin-left: 36pt"><strong><em> }<br />
</em></strong></p>
<p style="margin-left: 36pt"><strong><em> //Open the Dialog<br />
</em></strong></p>
<p style="margin-left: 36pt"><strong><em> function OpenModalDialog(dlgURL)<br />
</em></strong></p>
<p style="margin-left: 36pt"><strong><em> {<br />
</em></strong></p>
<p style="margin-left: 36pt"><strong><em> var options = {<br />
</em></strong></p>
<p style="margin-left: 36pt"><strong><em> url: dlgURL,<br />
</em></strong></p>
<p style="margin-left: 36pt"><strong><em> width: 700,<br />
</em></strong></p>
<p style="margin-left: 36pt"><strong><em> height: 700,<br />
</em></strong></p>
<p style="margin-left: 36pt"><strong><em> dialogReturnValueCallback: DialogCallback<br />
</em></strong></p>
<p style="margin-left: 36pt"><strong><em> };<br />
</em></strong></p>
<p style="margin-left: 36pt"><strong><em> SP.UI.ModalDialog.showModalDialog(options);<br />
</em></strong></p>
<p style="margin-left: 36pt"><strong><em> }<br />
</em></strong></p>
<p style="margin-left: 36pt"><strong><em>&lt;/script&gt;<br />
</em></strong></p>
<p style="margin-left: 36pt">
<p style="margin-left: 36pt"><strong><em>//Link to InfoPath Form<br />
</em></strong></p>
<p style="margin-left: 36pt"><strong><em>&lt;a href="javascript:OpenModalDialog('http://docs.company.com/sites/active/_layouts/FormServer.aspx?XsnLocation=http://docs.company.com/sites/active/Form%20Templates/Form%20Template.xsn&amp;amp;SaveLocation=http%3A%2F%2Fdocs%2Ecompany%2Ecom%2Fsites%2Factive%2FDocuments&amp;amp;DefaultItemOpen=1');" onmouseover="javascript:window.status='';return true;" onmousedown="javascript:window.status='';return true;"&gt;Coolest Form Ever&lt;/a&gt;<br />
</em></strong></p>
<p>So, you see that I have gotten rid of the "Source" parameter in the Query String, as that still breaks the form if you send it something that is in a different site collection than the template, but the UX is about 100 times better than having a popup or (even worse) sending them to a page that is on a different site collection than where they started.</p>
<p>I still need to move this out of the CEWP before it is ready for prime time, but just think about the implications here.  This is a bona fide slam dunk and a huge win for Microsoft by allowing us to quickly deliver solutions that are in line with what others are doing in the industry.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.themackpage.com/2010/05/06/using-the-sharepoint-2010-dialog-platform-with-forms-services/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Two Helpful Web Parts for FREE!!!</title>
		<link>http://www.themackpage.com/2009/06/23/two-helpful-web-parts-for-free/</link>
		<comments>http://www.themackpage.com/2009/06/23/two-helpful-web-parts-for-free/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 04:28:11 +0000</pubDate>
		<dc:creator>Joe Mack</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[SharePoint]]></category>

		<guid isPermaLink="false">http://www.themackpage.com/2009/06/23/two-helpful-web-parts-for-free/</guid>
		<description><![CDATA[Since the response was so great to our articles regarding using the QueryString to pass information to PageViewer web parts, I have decided to make both web parts available, as SharePoint features deployed at the Site Collection level.
You can download the web parts at my company web site:&#160; www.theportalgroup.biz
Just click on “Downloads”, register for free, [...]]]></description>
			<content:encoded><![CDATA[<p>Since the response was so great to our articles regarding using the QueryString to pass information to PageViewer web parts, I have decided to make both web parts available, as SharePoint features deployed at the Site Collection level.</p>
<p>You can download the web parts at my company web site:&#160; <a href="http://www.theportalgroup.biz">www.theportalgroup.biz</a></p>
<p>Just click on “Downloads”, register for free, and they are all yours.</p>
<p><strong>UPDATE:</strong>&#160; Registration is no longer required…and in an unrelated note, special thanks to the over 200 new registered users with a username of “asdf”…I really appreciate it. <strong>&lt;grin /&gt;</strong></p>
<p>In case you have not read the blog posts yet (and don’t want to), here is the basic overview:</p>
<ul>
<li><strong>QueryString Pass-Thru Web Part.</strong>&#160; The first web part will pass through the entire QueryString from the parent Web Part Page, append it to a Base URL, which the user can configure in the tool pane, and display the contents at the concatenated URL in the PageViewer web part.&#160; This is especially useful when you want to link to display content from several external pages that are all part of the same site, with a URL format that looks something like this:&#160; <a href="http://intranet.company.net/Default.aspx?pageid=420">http://intranet.company.net/Default.aspx?pageid=420</a>.&#160; If you wanted to display the contents of 40 different pages in SharePoint using the standard PageViewer web part, you would need 40 separate web part pages, each hard-wired to the target URL.&#160; Using the QueryString Pass-Thru Web Part, you can just set up one Web Part Page, and pass it a QueryString parameter with the pageid every time you want to use that page. </li>
<li><strong>QueryString Parameter Pass-Thru Web Part.</strong>&#160; This web part will pass through a QueryString parameter called ‘Url’ (‘url’ and ‘URL’ will work as well), which contains a properly formatted URL, to a PageViewer web part that will display the contents at that URL.&#160; This is useful for a situation where you want to display content from several different external pages that are specific and separate pages, not just differentiated by the QueryString (e.g. <a href="http://intranet.company.net/hr/Deafult.aspx">http://intranet.company.net/hr/Deafult.aspx</a>, <a href="http://intranet.company.net/finance/Default.aspx">http://intranet.company.net/finance/Default.aspx</a>, etc.)&#160; The benefits are the same as the QueryString Pass-Thru Web Part…you only need one web part page that you can use to connect out to any page, vice needing a separate web part page for every connection, if you were using the standard PageViewer web part. </li>
</ul>
<p>There are a few caveats to keep in mind as well.</p>
<ul>
<li>QueryString Pass-Thru Web Part.&#160; You cannot use a QueryString parameter named ‘id’.&#160; SharePoint will think it needs to look for an ID of its own with that value, and you will get an error on the page. </li>
<li>QueryString Paramter Pass-Thru Web Part.&#160; Be careful of the characters you are using in your ‘Url’ parameter.&#160; It is a good idea to use the HTML character escape sequences.&#160; For instance, if you want to pass a URL that has a query string, you will need to use the escape sequence for the question mark and ampersand(s) or else the code with think the ‘Url’ parameter has ended before you wanted it to end. </li>
</ul>
<p>Hope you enjoy the web parts, and please feel free to let us know what you think.</p>
<p>Oh – one more thing.&#160; If you are interested in expanding on these or otherwise developing them yourself, you can get to the blog posts at the links below.&#160; The first one even has a Screencast that might help those without a lot of SharePoint development experience.</p>
<p><a href="http://www.themackpage.com/2009/05/27/making-a-dynamic-pageviewer-web-part-using-requestquerystring/" target="_blank">Passing Through the Entire Query String</a></p>
<p><a href="http://www.themackpage.com/2009/05/27/making-a-dynamic-pageviewer-web-part-using-requestquerystring-redux/" target="_blank">Passing Through a Single Parameter in the Query String</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.themackpage.com/2009/06/23/two-helpful-web-parts-for-free/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Software You Need &#8211; AXIGEN Mail Server</title>
		<link>http://www.themackpage.com/2009/06/01/the-software-you-need-%e2%80%93-axigen-mail-server/</link>
		<comments>http://www.themackpage.com/2009/06/01/the-software-you-need-%e2%80%93-axigen-mail-server/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 14:16:17 +0000</pubDate>
		<dc:creator>Joe Mack</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[SharePoint]]></category>

		<guid isPermaLink="false">http://www.themackpage.com/2009/06/01/the-software-you-need-%e2%80%93-axigen-mail-server/</guid>
		<description><![CDATA[&#160;
If you are like me and do a lot of demos, especially ones that are running within a virtual environment (Virtual PC, VMWare Server, etc.) you have probably struggled with the best way to demonstrate the e-mail capabilities of whatever you are going to demo.&#160; In my case, Microsoft SharePoint is what I am trying [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>
<p>If you are like me and do a lot of demos, especially ones that are running within a virtual environment (Virtual PC, VMWare Server, etc.) you have probably struggled with the best way to demonstrate the e-mail capabilities of whatever you are going to demo.&#160; In my case, Microsoft SharePoint is what I am trying to show, and although there are a few integration touch points only present in Microsoft Exchange, it is a resource hog and kind of a pain to install and maintain, especially if you are not an Exchange administrator.</p>
<p>Enter AXIGEN mail server.&#160; First things first, I have never played around with the “pay” versions of AXIGEN, but according to their web site, the free “Office Edition” is essentially their full-featured product, with a restriction of 5 users and 1 domain…more than enough for a small office, or a demo VPC or VM.</p>
<p>On their web site, they claim that you will have a 10-minute install, which is true…although if you are going to install and use their Active Directory extension, you can probably add another 5 minutes or so.&#160; All told, the very first time I used it, it took around 20 minutes from the time I started the download until I was up and running, with integration to my Windows Server 2003 Domain (Active Directory) and robust full-featured web mail running on a custom port of my choosing.&#160; The second time I set it up, it took me all of 6 or 7 minutes, start to finish.</p>
<p>I have not played around with AXIGEN versions for any other operating system than Windows, but if my experience on Windows is typical of how it works on other operating systems, then you should have nothing to worry about.</p>
<p>I cannot say enough positive things about this little product.&#160; In fact, some time in the next few months, Mack is going to start bringing a lot of his stuff “in house”, as in having a home office with one or 2 “server class” machines, getting a block of static IP addresses, and starting to do a lot of my own hosting for certain domains that I manage, including e-mail.&#160; After my first exposure to AXIGEN, Microsoft would probably have to pay me to install and use Exchange.</p>
<p>Feel free to download the product and try it out yourself.&#160; You will NOT be disappointed.</p>
<p><a href="http://www.axigen.com" target="_blank">http://www.axigen.com</a></p>
<p>One more thing I would be remiss if I did not mention – it installs and runs on non-server Windows operating systems as well.&#160; Couple AXIGEN with Bamboo Solutions’ <a href="http://community.bamboosolutions.com/blogs/bambooteamblog/archive/2008/05/21/how-to-install-windows-sharepoint-services-3-0-sp1-on-vista-x64-x86.aspx" target="_blank">WssOnVista</a>, and I can do a full-featured demo within my host operating system, instead of even worrying about Virtual PC or VM Ware.&#160; Now THAT’S something worth telling people about!</p>
<p><span style="font-family: trebuchet ms; font-size: 7pt"></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.themackpage.com/2009/06/01/the-software-you-need-%e2%80%93-axigen-mail-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making a Dynamic PageViewer Web Part Using Request.QueryString Redux</title>
		<link>http://www.themackpage.com/2009/05/27/making-a-dynamic-pageviewer-web-part-using-requestquerystring-redux/</link>
		<comments>http://www.themackpage.com/2009/05/27/making-a-dynamic-pageviewer-web-part-using-requestquerystring-redux/#comments</comments>
		<pubDate>Wed, 27 May 2009 23:13:52 +0000</pubDate>
		<dc:creator>Joe Mack</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[SharePoint]]></category>

		<guid isPermaLink="false">http://www.themackpage.com/2009/05/27/making-a-dynamic-pageviewer-web-part-using-requestquerystring-redux/</guid>
		<description><![CDATA[So, as I was working away, setting up a Links list in SharePoint to take advantage of the QueryStringPageViewer Web Part discussed in my last blog post, I came upon a situation where I needed to do something slightly different.
The QueryStringPageViewer Web Part allows a user to configure the Web Part with a Base URL [...]]]></description>
			<content:encoded><![CDATA[<p>So, as I was working away, setting up a Links list in SharePoint to take advantage of the QueryStringPageViewer Web Part discussed in <a href="http://www.themackpage.com/2009/05/27/making-a-dynamic-pageviewer-web-part-using-requestquerystring/" target="_blank">my last blog post</a>, I came upon a situation where I needed to do something slightly different.</p>
<p>The QueryStringPageViewer Web Part allows a user to configure the Web Part with a Base URL attribute, then fills up the web part’s IFRAME by concatenating the Base URL with the query string of the web part page, using Page.Request.QueryString.&#160; The best use for this web part is when you have a bunch of pages you want to link to on a different server, where the URL format of those pages looks something like this:&#160; <strong>http://intranet.company.com/Default.aspx?pageid=4563</strong></p>
<p>But what about a situation where the existing pages are all distinct, such as:&#160; <strong>http://intranet.company.com/Finance.aspx</strong>, <strong>http://intranet.company.com/HR.aspx</strong>, <strong>http://intranet.company.com/Manufacturing.aspx</strong>, etc.?&#160; Let’s say you had 40 of those pages that you wanted to expose within SharePoint in an effort to incorporate existing content sources.&#160; If you were going to use the standard PageViewer Web Part, you will need to create 40 separate Web Part Pages, each with a PageViewer Web Part wired up to the URL of one of the 40 pages.</p>
<p>So, what about making a generic web part that uses a query string parameter from the web part page, a la my previous blog post referenced above, to dynamically set the source of a PageViewer web part?&#160; What if you could deploy that simple web part on a “generic” web part page and reference it anywhere in your SharePoint implementation that you need to use a PageViewer web part?&#160; Would you rather have 40 instances of the PageViewer web part in your environment or one instance of this new web part, called the DynamicPageViewer web part?</p>
<p>As you would expect, the code is very similar to the code from my last blog post, as we will be using the Page.Request.QueryString object once again.&#160; Here are the steps you need to take to change that code to perform this new function.&#160; More detailed instructions on creating the project, deploying the web part, etc., can be found in the last blog post.</p>
<p>Here are the steps required:</p>
<ul>
<li>Get the code from the previous version, where we use the entire query string.&#160; It is located here:&#160; <a href="http://www.themackpage.com/files/Dynamic-PageViewer-Web-Part.txt">http://www.themackpage.com/files/Dynamic-PageViewer-Web-Part.txt</a> </li>
<li>Find and remove this code:&#160;
<pre class="csharp"><span style="color: #008080; font-style: italic;">//Set custom attribute to allow user to specify Base URL in Tool Pane</span>
<span style="color: #0600FF;">private</span> <span style="color: #FF0000;">string</span> _baseURL = &amp;quot;&amp;quot;;
<span style="color: #000000;">&#91;</span>WebBrowsable<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">true</span><span style="color: #000000;">&#41;</span>,
Personalizable<span style="color: #000000;">&#40;</span>PersonalizationScope.<span style="color: #0000FF;">Shared</span><span style="color: #000000;">&#41;</span>,
Category<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Base URL Settings&quot;</span><span style="color: #000000;">&#41;</span>,
WebDisplayName<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Base URL&quot;</span><span style="color: #000000;">&#41;</span>,
WebDescription<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Supply the Base URL for the page viewer query string web part.&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
&nbsp;
<span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> baseURL
<span style="color: #000000;">&#123;</span>
    get
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">return</span> <span style="color: #0600FF;">this</span>._baseURL;
    <span style="color: #000000;">&#125;</span>
    set
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">this</span>._baseURL = value;
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre>
</li>
<li>In the RenderWebPart method, replace this code:&#160;
<pre class="csharp">NameValueCollection queryString = Page.<span style="color: #0000FF;">Request</span>.<span style="color: #0000FF;">QueryString</span>;
<span style="color: #FF0000;">string</span> URL = <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">baseURL</span>;
<span style="color: #FF0000;">int</span> paramCount = <span style="color: #FF0000;">0</span>;
&nbsp;
<span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>queryString.<span style="color: #0000FF;">Count</span> &gt; <span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #008080; font-style: italic;">// Set up URL as having a Query String</span>
    URL += <span style="color: #808080;">&quot;?&quot;</span>;
&nbsp;
    <span style="color: #008080; font-style: italic;">// Loop through QueryString collection and add all name/value pairs to 'URL'</span>
    <span style="color: #0600FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> qsName <span style="color: #0600FF;">in</span> queryString<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #008080; font-style: italic;">// Add name/value pair for current key to the URL</span>
        URL += qsName + <span style="color: #808080;">&quot;=&quot;</span> + queryString<span style="color: #000000;">&#91;</span>qsName<span style="color: #000000;">&#93;</span>;
&nbsp;
        <span style="color: #008080; font-style: italic;">// Add ampersand for all but the last query string parameter</span>
        paramCount++;
        <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>paramCount &lt; queryString.<span style="color: #0000FF;">Count</span><span style="color: #000000;">&#41;</span>
            URL += <span style="color: #808080;">&quot;&amp;&quot;</span>;
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre>
</li>
</ul>
<p>with this: </p>
<pre class="csharp">NameValueCollection queryString = Page.<span style="color: #0000FF;">Request</span>.<span style="color: #0000FF;">QueryString</span>;
<span style="color: #FF0000;">string</span> URL = <span style="color: #808080;">&quot;&quot;</span>;
<span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>queryString.<span style="color: #0000FF;">Count</span> &gt; <span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #008080; font-style: italic;">// Loop through QueryString collection</span>
    <span style="color: #0600FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> qsName <span style="color: #0600FF;">in</span> queryString<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>qsName.<span style="color: #0000FF;">ToLower</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> == <span style="color: #808080;">&quot;url&quot;</span><span style="color: #000000;">&#41;</span>
            URL = queryString<span style="color: #000000;">&#91;</span>qsName<span style="color: #000000;">&#93;</span>;
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre>
<p>See?&#160; I told you it was super simple!</p>
<p>Once you get the web part deployed and on a web part page, type in any random query string at the end of the URL for the web part page, making sure to include a parameter called <strong>url</strong> that actually contains a valid URL (note the use of "ToLower()" in the code, so <strong>url</strong>, <strong>URL</strong> and <strong>Url</strong> are all supported).  For example, replace <strong>http://intranet.company.com/TestSite/Pages/WebPartTest.aspx</strong> with <strong>http://intranet.company.com/TestSite/Pages/WebPartTest.aspx?pageid=1999&amp;red=green&amp;url=http://autos.msn.com&amp;napster=bad</strong></p>
<p>The custom web part should be blank, and then when you add the query string with the url parameter, it will fill up with the MSN Autos page.</p>
<p><strong>ADDENDUM:</strong></p>
<p>In certain situations, you will need to use url escape codes in the ‘url’ parameter.&#160; For instance, if the URL you are targeting has a query string, you need to use the escape code for the “question mark” (<strong>%3F</strong>) to start the query string and use the escape code for the “ampersand” (<strong>%26</strong>)to delimit the parameters.&#160; If you fail to use the escape codes, you will not achieve the desired results.&#160; Using the escape code for “equals” (<strong>%3D</strong>)is not required, although it might make sense to adopt a standard convention where you use the escape code for all eligible characters within the ‘url’ parameter.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.themackpage.com/2009/05/27/making-a-dynamic-pageviewer-web-part-using-requestquerystring-redux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making a Dynamic PageViewer Web Part Using Request.QueryString</title>
		<link>http://www.themackpage.com/2009/05/27/making-a-dynamic-pageviewer-web-part-using-requestquerystring/</link>
		<comments>http://www.themackpage.com/2009/05/27/making-a-dynamic-pageviewer-web-part-using-requestquerystring/#comments</comments>
		<pubDate>Wed, 27 May 2009 15:16:33 +0000</pubDate>
		<dc:creator>Joe Mack</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[SharePoint]]></category>

		<guid isPermaLink="false">http://www.themackpage.com/2009/05/27/making-a-dynamic-pageviewer-web-part-using-requestquerystring/</guid>
		<description><![CDATA[Hopefully, all of you have read and implemented my guide to installing a SharePoint development environment for free.&#160; If not, you can find the link here:&#160; http://www.themackpage.com/2009/05/26/how-to-build-your-totally-free-sharepoint-development-environment/
If you are lucky enough to have a development environment with even better tools, as I am sure most of you do, then please feel free to use whatever [...]]]></description>
			<content:encoded><![CDATA[<p>Hopefully, all of you have read and implemented my guide to installing a SharePoint development environment for free.&#160; If not, you can find the link here:&#160; <a title="http://www.themackpage.com/2009/05/26/how-to-build-your-totally-free-sharepoint-development-environment/" href="http://www.themackpage.com/2009/05/26/how-to-build-your-totally-free-sharepoint-development-environment/" target="_blank">http://www.themackpage.com/2009/05/26/how-to-build-your-totally-free-sharepoint-development-environment/</a></p>
<p>If you are lucky enough to have a development environment with even better tools, as I am sure most of you do, then please feel free to use whatever best tools you have as you make your way through this.&#160; </p>
<p>Also, there is a supporting screencast for this blog post that contains much more detailed information.&#160; You can find it here:&#160; <a title="http://www.themackpage.com/screencasts/dynamic-pageviewer-web-part" href="http://www.themackpage.com/screencasts/dynamic-pageviewer-web-part" target="_blank">http://www.themackpage.com/screencasts/dynamic-pageviewer-web-part</a></p>
<p>Without further ado, let’s get down to it.&#160; Here are the steps to create your very own dynamic PaveViewer web part.</p>
<p><span id="more-48"></span></p>
<ul>
<li>Make a SharePoint Web Part project in your development environment of choice.&#160; For the purposes of this exercise, I will be using the generic <strong>Class Library</strong> project in Visual C# 2008 Express.&#160; If you are using the Visual Studio Extensions for WSS, then you will be able to skip the next few steps. </li>
<li>Rename the <strong>Class1.cs</strong> file in the Solution Explorer.&#160;&#160; </li>
<li>Right-click the class name and select <strong>Rename</strong> </li>
<li>Change the name and hit <strong>Enter</strong> </li>
<li>Something cool in the 2008 dev tools (even the free one) is about to happen – you will be asked if you want the IDE to search and fix other instances of the reference to <strong>Class1</strong>.&#160; Click <strong>Yes</strong> and watch the class name in the editor change before your very eyes! </li>
</ul>
<li>Since we are going to be deploying this into the bin folder for one or more SharePoint web applications, instead of to the GAC, we need to allow partially trusted callers.
<ul>
<li>Go into <strong>AssemblyInfo.cs</strong> (it’s in the <strong>Properties</strong> folder) </li>
<li>Add the following statement at the top of the code:&#160;&#160;
<pre class="csharp">&nbsp;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Security</span>;</pre>
</li>
<li>Add the following code at the bottom of the file: </font>
<pre class="csharp">&nbsp;
<span style="color: #008080; font-style: italic;">// Allow partially trusted callers</span>
<span style="color: #000000;">&#91;</span>assembly: AllowPartiallyTrustedCallers<span style="color: #000000;">&#93;</span></pre>
</li>
<li>Save <strong>AssemblyInfo.cs</strong> </li>
</ul>
</li>
<li>Add references to System.Web and the SharePoint DLL to your project
<ul>
<li>Right-click the <strong>References</strong> folder and select <strong>Add Reference</strong> </li>
<li>Select <strong>System.Web</strong> under the <strong>.NET</strong> tab </li>
<li>Select <strong>Windows SharePoint Services</strong> under the <strong>.NET</strong> tab </li>
</ul>
</li>
<li>Ensure that your list of using statements at the top of your class file looks like this:&#160;&#160;&#160;
<pre class="csharp">&nbsp;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Collections</span>.<span style="color: #0000FF;">Generic</span>;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Linq</span>;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Text</span>;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Web</span>;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Web</span>.<span style="color: #0000FF;">UI</span>;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Web</span>.<span style="color: #0000FF;">UI</span>.<span style="color: #0000FF;">WebControls</span>;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Web</span>.<span style="color: #0000FF;">UI</span>.<span style="color: #0000FF;">WebControls</span>.<span style="color: #0000FF;">WebParts</span>;
<span style="color: #0600FF;">using</span> Microsoft.<span style="color: #0000FF;">SharePoint</span>;
<span style="color: #0600FF;">using</span> Microsoft.<span style="color: #0000FF;">SharePoint</span>.<span style="color: #0000FF;">WebControls</span>;
<span style="color: #0600FF;">using</span> Microsoft.<span style="color: #0000FF;">SharePoint</span>.<span style="color: #0000FF;">WebPartPages</span>;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">ComponentModel</span>;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Collections</span>.<span style="color: #0000FF;">Specialized</span>;
&nbsp;</pre>
</li>
<li>Make sure that your class implements the SHAREPOINT (as in, NOT to System.Web) version of the WebPart class, like so:&#160;
<pre class="csharp">&nbsp;
<span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> QSPVWP : Microsoft.<span style="color: #0000FF;">SharePoint</span>.<span style="color: #0000FF;">WebPartPages</span>.<span style="color: #0000FF;">WebPart</span></pre>
</li>
<li>Next, we will add the code for a custom attribute that users will be able to set in the Web Part’s Tool Pane.&#160; Let’s call it something like “Base URL”.&#160; Here is the code to do that:&#160;&#160;
<pre class="csharp">&nbsp;
<span style="color: #008080; font-style: italic;">//Set custom attribute to allow user to specify Base URL in Tool Pane</span>
<span style="color: #0600FF;">private</span> <span style="color: #FF0000;">string</span> _baseURL = <span style="color: #808080;">&quot;&quot;</span>;
<span style="color: #000000;">&#91;</span>WebBrowsable<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">true</span><span style="color: #000000;">&#41;</span>,
Personalizable<span style="color: #000000;">&#40;</span>PersonalizationScope.<span style="color: #0000FF;">Shared</span><span style="color: #000000;">&#41;</span>,
Category<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Base URL Settings&quot;</span><span style="color: #000000;">&#41;</span>,
WebDisplayName<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Base URL&quot;</span><span style="color: #000000;">&#41;</span>,
WebDescription<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Supply the Base URL for the page viewer query string web part.&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
&nbsp;
<span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> baseURL
<span style="color: #000000;">&#123;</span>
    get
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">return</span> <span style="color: #0600FF;">this</span>._baseURL;
    <span style="color: #000000;">&#125;</span>
    set
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">this</span>._baseURL = value;
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;</pre>
</li>
<li>The next step is to override the RenderWebPart method.&#160; Intellisense should help you out here.&#160; Once you have the method shelled out, delete the base.RenderWebPart(); line that came with the original method.&#160; </li>
<li>Add in a couple of variable definitions like so:&#160;
<pre class="csharp">&nbsp;
NameValueCollection queryString = Page.<span style="color: #0000FF;">Request</span>.<span style="color: #0000FF;">QueryString</span>;
<span style="color: #FF0000;">string</span> URL = <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">baseURL</span>;
<span style="color: #FF0000;">int</span> paramCount = <span style="color: #FF0000;">0</span>;
&nbsp;</pre>
</li>
<li>Next, we are going to loop through the collection of QueryString parameters in the web part’s page, and add them to the Base URL.&#160; Here is the code for this step:&#160;
<pre class="csharp">&nbsp;
<span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>queryString.<span style="color: #0000FF;">Count</span> &gt; <span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #008080; font-style: italic;">// Set up URL as having a Query String</span>
    URL += <span style="color: #808080;">&quot;?&quot;</span>;
&nbsp;
    <span style="color: #008080; font-style: italic;">// Loop through QueryString collection and add all name/value pairs to 'URL'</span>
    <span style="color: #0600FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> qsName <span style="color: #0600FF;">in</span> queryString<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #008080; font-style: italic;">// Add name/value pair for current key to the URL</span>
        URL += qsName + <span style="color: #808080;">&quot;=&quot;</span> + queryString<span style="color: #000000;">&#91;</span>qsName<span style="color: #000000;">&#93;</span>;
&nbsp;
        <span style="color: #008080; font-style: italic;">// Add ampersand for all but the last query string parameter</span>
        paramCount++;
        <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>paramCount &lt; queryString.<span style="color: #0000FF;">Count</span><span style="color: #000000;">&#41;</span>
            URL += <span style="color: #808080;">&quot;&amp;&quot;</span>;
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;</pre>
</li>
<li>Now that we have concatenated all that stuff to make our URL, which includes the QueryString parameters from the web part page, we need to actually use it to display the URL in the web part.&#160; I figured out how to do this by putting a standard PageViewer Web Part on the page and then viewing the source.&#160; There are several attributes you may or may not care about setting, but the <strong>Src</strong> attribute is the important one.&#160; Here is the code to tell the web part’s IFRAME to serve up the URL:&#160;
<pre class="csharp">&nbsp;
<span style="color: #FF0000;">string</span> name = <span style="color: #808080;">&quot;QueryStringPageViewer_&quot;</span> + <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">UniqueID</span>;
output.<span style="color: #0000FF;">AddAttribute</span><span style="color: #000000;">&#40;</span>HtmlTextWriterAttribute.<span style="color: #0000FF;">Id</span>, name, <span style="color: #0600FF;">false</span><span style="color: #000000;">&#41;</span>;
output.<span style="color: #0000FF;">AddAttribute</span><span style="color: #000000;">&#40;</span>HtmlTextWriterAttribute.<span style="color: #0000FF;">Name</span>, name, <span style="color: #0600FF;">false</span><span style="color: #000000;">&#41;</span>;
output.<span style="color: #0000FF;">AddAttribute</span><span style="color: #000000;">&#40;</span>HtmlTextWriterAttribute.<span style="color: #0000FF;">Width</span>, <span style="color: #808080;">&quot;100%&quot;</span>, <span style="color: #0600FF;">false</span><span style="color: #000000;">&#41;</span>;
output.<span style="color: #0000FF;">AddAttribute</span><span style="color: #000000;">&#40;</span>HtmlTextWriterAttribute.<span style="color: #0000FF;">Height</span>, <span style="color: #808080;">&quot;100%&quot;</span>, <span style="color: #0600FF;">false</span><span style="color: #000000;">&#41;</span>;
output.<span style="color: #0000FF;">AddAttribute</span><span style="color: #000000;">&#40;</span>HtmlTextWriterAttribute.<span style="color: #0000FF;">Src</span>, URL, <span style="color: #0600FF;">false</span><span style="color: #000000;">&#41;</span>;
output.<span style="color: #0000FF;">AddAttribute</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;ddf_src&quot;</span>, URL, <span style="color: #0600FF;">false</span><span style="color: #000000;">&#41;</span>;
output.<span style="color: #0000FF;">AddAttribute</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;frameBorder&quot;</span>, <span style="color: #808080;">&quot;0&quot;</span>, <span style="color: #0600FF;">false</span><span style="color: #000000;">&#41;</span>;
output.<span style="color: #0000FF;">RenderBeginTag</span><span style="color: #000000;">&#40;</span>HtmlTextWriterTag.<span style="color: #0000FF;">Iframe</span><span style="color: #000000;">&#41;</span>;
output.<span style="color: #0000FF;">RenderBeginTag</span><span style="color: #000000;">&#40;</span>HtmlTextWriterTag.<span style="color: #0000FF;">Div</span><span style="color: #000000;">&#41;</span>;
output.<span style="color: #0000FF;">Write</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;IFrames not supported by this browser&quot;</span><span style="color: #000000;">&#41;</span>;
output.<span style="color: #0000FF;">RenderEndTag</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>; <span style="color: #008080; font-style: italic;">//Div</span>
output.<span style="color: #0000FF;">RenderEndTag</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>; <span style="color: #008080; font-style: italic;">//Iframe</span>
&nbsp;</pre>
</li>
<li>You should now be done coding! </li>
<li>The next step is to strongly name our assembly.
<ul>
<li>Right-click the project name and select <strong>Properties</strong> </li>
<li>Select the <strong>Signing</strong> tab </li>
<li>Check the box for <strong>Sign the assembly</strong> </li>
<li>In the dropdown, select <strong>&lt;New&gt;</strong> </li>
<li>Name your strong name key something like <strong>&lt;AssemblyName&gt;.snk</strong> (substituting the actual name of your assembly, of course) </li>
<li>Uncheck the password box </li>
<li>Click <strong>OK</strong> </li>
</ul>
</li>
<li>Build the project and copy the DLL from your project’s bin folder to the bin folder of a SharePoint web application.&#160; These are probably located somewhere like:&#160; <strong>C:\Inetpub\wwwroot\wss\VirtualDirectories\intranet.company.com80\bin</strong> </li>
<li>Now, we need to edit the <strong>web.config</strong> file for our web application.&#160; It should be located at a location that looks something like this:&#160; <strong>C:\Inetpub\wwwroot\wss\VirtualDirectories\intranet.company.com80</strong>
<ul>
<li>Open <strong>web.config</strong> in your preferred editor </li>
<li>Look for the <strong>trust</strong> element and make sure that it is not using <strong>WSS_Minimal</strong>.&#160; If so, change it like so:&#160;
<pre class="xml">&nbsp;
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;trust</span> <span style="color: #000066;">level</span>=<span style="color: #ff0000;">&quot;WSS_Medium&quot;</span> <span style="color: #000066;">originUrl</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
&nbsp;</pre>
</li>
<li>Add the new web part to the list of <strong>Safe Controls</strong> in the config file.&#160; To do this, you will need the Assembly Name, Version, Culture, Public Key Token, NameSpace and Class/Type Name.&#160; The easiest way to get this (and a whole bunch of other stuff) is to use Reflector.&#160; It’s free and you can get it here:&#160; <a title="http://www.red-gate.com/products/reflector/" href="http://www.red-gate.com/products/reflector/" target="_blank">http://www.red-gate.com/products/reflector/</a>.&#160; For a VERY brief tutorial on how to use it to get the information you need, check out the supporting screencast for this blog post here:&#160; <a href="http://www.themackpage.com/screencasts/dynamic-pageviewer-web-part" target="_blank">http://www.themackpage.com/screencasts/dynamic-pageviewer-web-part</a>.&#160; Hop to the 20-minute mark in the screencast. </li>
<li>Save <strong>web.config</strong> </li>
<li>Do an <strong>iisreset</strong> </li>
</ul>
</li>
<li>The next step is to add the Web Part to the Web Part Gallery of your site collection.&#160;
<ul>
<li>From your site collection top-level site, go to the <strong>Site Settings</strong> </li>
<li>In the <strong>Galleries</strong> column, select <strong>Web Parts</strong> </li>
<li>When you see the list of Web Parts, click the <strong>New</strong> button </li>
<li>The list of Web Parts available is displayed in alphabetical order and they are displayed in the format &lt;AssemblyName&gt;.&lt;ClassName&gt;.&#160; Find your web part and check the box to its left </li>
<li>Scroll back up to top of the page and click the <strong>Populate Gallery</strong> button </li>
<li><strong>OPTIONAL, but a GOOD IDEA</strong> – click the icon to the right of your web part in the Web Parts Gallery to edit its settings.
<ul>
<li>Give it an intuitive <strong>Title</strong> – this will be the default name displayed on the title bar of the chrome of your web part </li>
<li>Give it a nice <strong>Description</strong> </li>
<li>Use the <strong>Specify your own value</strong> in the <strong>Group</strong> section … this will make it much easier to find your web part in the list of available web parts when you are adding it to a page </li>
<li>Click the <strong>OK</strong> button </li>
</ul>
</li>
</ul>
</li>
<li>Now, you can add the web part to any Web Part Page in your site collection.
<ul></ul>
<p>So, how do you use the Web Part?&#160; Just use the <strong>Modify Shared Web Part</strong> option and set the Base URL in the <strong>Base URL Settings</strong> area of the Tool Pane.&#160; Once you have done that, you should be good to go.&#160; Here is a very easy test to see if it is going to work for you.</p>
<ul>
<li>Set the Base URL to the following:&#160; <a href="http://www.google.com/search" target="_blank">http://www.google.com/search</a> </li>
<li>Under <strong>Appearance</strong>, set the web part to have a fixed height of around <strong>650 pixels</strong> </li>
<li>Click <strong>OK</strong> </li>
<li>Exit the Edit Mode </li>
<li>In another browser tab or window, execute a Google search </li>
<li>Grab the query string from the address bar of that tab/window…this is just everything from the “?” to the right…highlight it and Ctrl-C </li>
<li>Go back to the web part page and add the query string the the page URL using Ctrl-V </li>
<li>Hit <strong>Enter</strong>.&#160; The page should refresh with the Google search results displayed in the web part. </li>
<li>Congratulations!&#160; It’s working! </li>
</ul>
<p>That’s about it…pretty simple, huh?</p>
<p>There is one caveat –&gt; you cannot use a parameter called <strong>id</strong> (upper or lower case) in your QueryString within SharePoint.&#160; SharePoint will react to it in a decidedly negative way.&#160; If you don’t believe me, go back to your web part page with the Google results displayed in the web part and add the following text at the end of the URL: “&amp;id=420”.&#160; Hit <strong>Enter</strong> and see what happens.</p>
<p>Hope you enjoyed it.&#160; Remember, there is even more detail available on the screencast, which you can find here:&#160; <a href="http://www.themackpage.com/screencasts/dynamic-pageviewer-web-part" target="_blank">http://www.themackpage.com/screencasts/dynamic-pageviewer-web-part</a></p>
<p>Also, although I think just about all of the code is supplied above, here is a link to a text file that contains the C# code.&#160; If you have added the System.Web and Windows SharePoint Services references to your project, you should be able to cut and past the entire contents of the text file right into your class file.&#160; You can get the text file here:&#160; <a href="http://www.themackpage.com/files/Dynamic-PageViewer-Web-Part.txt" target="_blank">http://www.themackpage.com/files/Dynamic-PageViewer-Web-Part.txt</a></p>
</p>
</p>
</li>
]]></content:encoded>
			<wfw:commentRss>http://www.themackpage.com/2009/05/27/making-a-dynamic-pageviewer-web-part-using-requestquerystring/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
