This documentation is archived and is not being maintained.

GetVar Element (View)

Windows SharePoint Services 3

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Returns a variable in the context of rendering the page. Variables can be set either locally to the current level of XML or globally to the page.

  AutoHyperlink = "TRUE" | "FALSE"
  AutoHyperLinkNoEncoding = "TRUE" | "FALSE"
  AutoNewLine = "TRUE" | "FALSE"
  Default = "TRUE" | "FALSE"
  ExpandXML = "TRUE" | "FALSE"
  HTMLEncode = "TRUE" | "FALSE"
  Name = "Text"
  Scope ="Request"
    StripWS = "TRUE" | "FALSE"
  URLEncode = "TRUE" | "FALSE"
  URLEncodeAsURL = "TRUE" | "FALSE">




Optional Boolean. TRUE to surround text with <A> tags if the text appears like a hyperlink, for example,


Optional Boolean. TRUE to surround text with <A> tags if the text appears like a hyperlink (for example, but without HTML encoding.


Optional Boolean. TRUE to insert <BR> tags into the text stream and to replace multiple spaces with a non-breaking space (&nbsp;).


Optional Text. Renders the text assigned to this attribute if the value returned by the Select attribute of another element is an empty string.


Optional Boolean. TRUE to re-pass the rendered content through the Collaborative Application Markup Language (CAML) interpreter, which allows CAML to render CAML.


Optional Boolean. TRUE to convert embedded characters so that they are displayed as text in the browser. In other words, characters that could be confused with HTML tags are converted to entities.


Required Text. The name of the variable.


If set to Request, the variable is globally available on the page.


Optional Boolean. TRUE to remove white space from the beginning and end of the value returned by the element.


Optional Boolean. TRUE to convert special characters, such as spaces, to quoted UTF-8 format, for example, %c3%ab for character ë.


Optional Boolean. Like URLEncode, but TRUE to specify that the string to encode is a path component of a URL so that forward slashes ("/") are not encoded.

Minimum: 0

Maximum: Unbounded

The GetVar element is often used within an Expr element in a Switch or IfEqual element.

If Scope="Request" is specified in the SetVar element, a variable assignment will take effect anywhere on the current page. Otherwise, the assignment affects only children of the SetVar element.

The following example uses the GetVar element to return current filtering information for determining what text to display in the toolbar above the list.

      <GetVar Name="Filter" />
   <Case Value="1">
      <HTML>Hide Filter Choices</HTML>
            <GetVar Name="FilterField1" />
         <Case Value="">
            <HTML>Change Filter</HTML>

If filter choices are open on the list and the Filter variable contains 1, "Hide Filter Choices" is displayed. If not, the default action implements a second Switch statement that evaluates a second variable, FilterField1. If the value of FilterField1 is an empty string, then no filter is applied and "Filter" is displayed in the toolbar; otherwise, the default action is to display "Change Filter."