13.4. Tokens of Affection

Although largely self-contained, Web Parts do not operate in a vacuum. They are part of a larger framework that includes Web Part Zones, Web Part Pages, and ultimately, SharePoint itself. Many aspects of Web Part development are of interest only to server-side programmers. Some, however, revolve around client presentation, and allow Web Parts to interact with each other.

The most important of these, the Web Part Services Component (WPSC), is discussed in the next chapter. Other aspects can be useful to you even without the WPSC. In particular, the Web Part Page framework offers several tokens you can use in your Content Editor Web Part to ascertain things about the environment in which your part exists. Tokens are essentially placeholders. They are strings of text that are replaced at run time with appropriate real information.

There are four tokens, and each token is delimited by an underscore (_) character both before and after the token name:

  • _WPQ_

  • _LogonUser_

  • _WPID_

  • _WPR_

When a Web Part is rendered, SharePoint looks for occurrences of these tokens in the content, and replaces them with values appropriate to that Web Part's context. Token names are case sensitive.

Token replacement occurs for all Web Parts that use the framework's render method, not just Content Editors.

13.4.1. The _WPQ_ Token

One of the great things about using a modular development framework like Web Parts is the capability to place components on pages as needed. Users can add ...

Get Professional Microsoft® SharePoint® Designer 2007 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.