GetVar Element (View)
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.
<GetVar 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"> </GetVar>
Optional Boolean. TRUE to surround text with <A> tags if the text appears like a hyperlink, for example, www.microsoft.com.
Optional Boolean. TRUE to surround text with <A> tags if the text appears like a hyperlink (for example, www.microsoft.com) 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 ( ).
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.
The following example uses the GetVar element to return current filtering information for determining what text to display in the toolbar above the list.
<Switch> <Expr> <GetVar Name="Filter" /> </Expr> <Case Value="1"> <HTML>Hide Filter Choices</HTML> </Case> <Default> <Switch> <Expr> <GetVar Name="FilterField1" /> </Expr> <Case Value=""> <HTML>Filter</HTML> </Case> <Default> <HTML>Change Filter</HTML> </Default> </Switch> </Default> </Switch>
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."