Share via

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)


Protected Friend Function ReplaceTokens ( _
    input As String _
) As String
Dim input As String
Dim returnValue As String

returnValue = Me.ReplaceTokens(input)
protected internal string ReplaceTokens(
    string input


  • input
    Type: System.String

    A string that requires token replacement.

Return value

Type: System.String
The input string with token values replaced.


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.


Replacement value


ClassResourcePath property


Qualifier property


Request.ServerVariables( "LOGON_USER" )


ID property (Control.ID)


The LCID of the Web site


ServerRelativeClassResourcePath property


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_"));

See also


WebPart class

WebPart members

Microsoft.SharePoint.WebPartPages namespace