This section describes two options for Web Parts that use relative URLs: ASP or VBScript code. These options describe a stand-alone Web Part. The ASP and VBScript code samples enable you to use the same Web Part when accessing the server by using NetBIOS, internal FQDN, or external FQDN. The samples contain two relative links and some very basic ASP code.
Both code samples perform the same task. The samples are provided to demonstrate two ways to perform the same task.
<HTML> <BODY> <% Response.write request.servervariables("Logon_User") %> <p> <A Href="../" Target="new">Home</a><p> <A Href="../Portal/Document%20Library/" Target="new">Document Library</a> </BODY> </HTML>
The Portal folder is a hidden folder.
You can create a stand-alone Web Part containing relative links.
Long commented lines and some code lines wrap to the next line in the following sample. For best results, copy the code sample and paste it directly into Microsoft Notepad.
<?xml version="1.0"?> <WebPart xmlns="urn:schemas-microsoft-com:webpart:" version="1.0.0"> <Title>Web Part Sample with relative URLs</Title> <Description>How to create a Web Part with relative URLs</Description> <Content><![CDATA[ 'Generic Web Part Function. REQUIRED. Function GetContent(nod) Dim strWorkspaceUrl 'Variable to store calculated URL of user On Error Resume Next 'BEGIN COMMENTS 'NOTE: ExtractWorkspaceURL and GetServerVariable are function calls to TahoeUtils.inc. ' We cannot guarantee backward compatibility with future SPs or versions of SharePoint Portal Server. ' It is recommended that you create your own standard include library to retrieve the URL of the user. ' Once you create your library, include it in DashboardExtensions.vbs (see DDRK for more information). 'IMPORTANT: DO NOT modify TahoeUtils.inc in any way. Modifications may break your portal and are not supported. 'END COMMENTS strWorkspaceUrl = ExtractWorkspaceUrl(GetDBProtocol() & _ GetServerVariable("SERVER_NAME") & GetServerVariable("URL")) If Err.Number <> 0 Then Exit Function strHtmlRet = request.servervariables("Logon_User") & vbCRLF 'Build up HTML output to a string 'Add a relative URL link with strWorkspaceUrl strHtmlRet = strHtmlRet & "<p>" strHtmlRet = strHtmlRet & "<a target=new href=""" & _ strWorkspaceUrl & "/Portal"">" & vbCRLF strHtmlRet = strHtmlRet & "Portal" & vbCRLF strHtmlRet = strHtmlRet & "</a>" & vbCRLF 'Add another link strHtmlRet = strHtmlRet & "<p>" strHtmlRet = strHtmlRet & "<a target=new href=""" & _ strWorkspaceUrl & "/Portal/Document Library"">" & vbCRLF strHtmlRet = strHtmlRet & "Document Library" & vbCRLF strHtmlRet = strHtmlRet & "</a>" & vbCRLF 'Return string to Dashboard GetContent = strHtmlRet End Function ]]></Content> <ContentType>1</ContentType> <IsVisible>1</IsVisible> <AllowRemove>1</AllowRemove> <HasFrame>1</HasFrame> <AllowMinimize>1</AllowMinimize> <FrameState>0</FrameState> <RequiresIsolation>0</RequiresIsolation> <CacheBehavior>0</CacheBehavior> <CacheTimeout>0</CacheTimeout> <DetailLink></DetailLink> <CustomizationLink></CustomizationLink> <IsIncluded>1</IsIncluded> <PartOrder>0</PartOrder> <Zone>3</Zone> </WebPart>