Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>While I think it's a bad idea to put the credentials of a user in a URL (anyone will be able to see this by viewing the page's HTML source), here's how you could accomplish what you want to do:</p> <p>Create a new class library project with a class that inherits from <code>Microsoft.SharePoint.WebPartPages.WebPartPage</code>. Something like:</p> <pre><code>namespace MyNameSpace.WebPagePages { public class MyWebPartPage : Microsoft.SharePoint.WebPartPages.WebPartPage { protected Microsoft.SharePoint.WebPartPages.PageViewerWebPart myPageViewerWebPart; protected override void OnLoad(EventArgs e) { base.OnLoad(e); // logic to create your URL string url = "http://blah/blah"; // set the URL myPageViewerWebPart.ContentLink = url; } } } </code></pre> <p>You'll need to sign the assembly and deploy it to the GAC. Using SharePoint Solution (WSP) is the recommended way to do this (but not the point of this answer).</p> <p>You now need to modify the ASPX page containing your web part as follows:</p> <ol> <li>Change the <code>Inherits</code> attribute of the <code>&lt;%@ Page %&gt;</code> directive to the fully qualified type name of the above class. It will look something like: <em>MyNameSpace.WebPagePages.MyWebPartPage, MyNameSpace.WebPagePages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b538f318242c0b01</em></li> <li>Give the web part an <code>ID</code> attribute with a value that matches the name of the web part in the code-behind class. In this example: <code>&lt;WebPartPages:PageViewerWebPart runat="server" ID="myPageViewerWebPart"&gt;</code></li> </ol> <p>That should do it. If you've not done it before, creating the class and deploying it to the GAC will be the tricky bits, but they're easy when you know how. Tools like <a href="http://channel9.msdn.com/posts/kirke/SharePoint-for-Developers-Part-1-Introducing-VSeWSS-13/" rel="nofollow noreferrer">VSeWSS</a>, <a href="http://www.codeplex.com/stsdev" rel="nofollow noreferrer">STSDEV</a>, and <a href="http://www.codeplex.com/wspbuilder" rel="nofollow noreferrer">WSPBuilder</a> (learn one first and then try the others) will help you accomplish this by creating WSP files (SharePoint Solutions) - something I highly recommend you take advantage of.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload