WebPart.ReplaceTokens method
Performs token replacement for a string, using the same algorithm used for URL-valued properties.
Namespace: Microsoft.SharePoint.WebPartPages
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'Declaration
Protected Friend Function ReplaceTokens ( _
input As String _
) As String
'Usage
Dim input As String
Dim returnValue As String
returnValue = Me.ReplaceTokens(input)
protected internal string ReplaceTokens(
string input
)
Parameters
input
Type: System.StringA string that requires token replacement.
Return value
Type: System.String
The input string with token values replaced.
Remarks
The Web Part architecture provides token replacement for Web Part base class properties that are defined as URLs, which include the HelpLink, DetailLink, PartImageLarge, and PartImageSmall properties. When a Web Part is rendered, values of these properties are scanned for the tokens listed in the following table, and those tokens are replaced with the values described in the following table. The Web Part property value itself is not changed.
Token |
Replacement value |
---|---|
_WPR_ |
ClassResourcePath property |
_WPQ_ |
Qualifier property |
_LogonUser_ |
Request.ServerVariables( "LOGON_USER" ) |
_WPID_ |
ID property (Control.ID) |
_WebLocaleId_ |
The LCID of the Web site |
_WPSRR_ |
ServerRelativeClassResourcePath property |
Examples
The following code example returns the value of the ClassResourcePath property by replacing the _WPR_ token. To view a more extensive example that passes HTML and ECMAScript (Microsoft JScript or JavaScript) that contains _WPQ_ tokens to the ReplaceTokens method before rendering the controls and script for a Web Part, see the client-side example provided for the ICellProvider interface.
output.Write(ReplaceTokens("Class Resource Path: _WPR_"))
output.Write(ReplaceTokens("Class Resource Path: _WPR_"));