다음을 통해 공유


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>

Attributes

Attribute

Description

AutoHyperlink

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

AutoHyperLinkNoEncoding

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.

AutoNewLine

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

Default

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

ExpandXML

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

HTMLEncode

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.

Name

Required Text. The name of the variable.

Scope

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

StripWS

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

URLEncode

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

URLEncodeAsUrl

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.

Child Elements

None

Parent Elements

Numerous

Occurrences

Minimum: 0

Maximum: Unbounded

Remarks

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.

Example

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."

See Also

Reference

SetVar Element (View)