Show All

# viewContext Attribute

Specifies a string that identifies an HTML element in the view.

## Type

    xsd:string

## Remarks

The viewContext attribute is an optional attribute of the xmlToEdit element.

The viewContext attribute names an HTML element that has the xd:CtrlId attribute. For example, `viewContext="myID"` in the form definition (.xsf) file corresponds to `xd:CtrlId="myID"` in the XSLT/HTML code for the view.

Note If the xd:CtrlId attribute is not used in the XSLT/HTML code for the view, then the viewContext attribute is ignored.

The viewContext attribute can be used to disambiguate controls when two instances of the same control have the same XML context (so that the XML context is identical). An example is a table of contents with chapter titles, and below, the same chapters repeated with full content. Two editWith elements for item="chapter" but different view contexts can specify distinct behavior.

## Example

The following is an example of the viewContext attribute as it is used in the xmlToEdit element:

    <xsf:editing>
       <xsf:xmlToEdit name="CD_10"
          item="/CustomUISample/CDCollection/CD"
          container="/CustomUISample">
          viewContext="cdID"
          <xsf:editWith caption="CD"
             xd:autogeneration="template"
             component="xCollection">
             <xsf:fragmentToInsert>
                <xsf:chooseFragment parent="CDCollection">
                   <CD>
                      <Title></Title>
                      <Artist></Artist>
                      <Tracks>
                         <Track></Track>
                         <Track></Track>
                      </Tracks>
                   </CD>
                </xsf:chooseFragment>
             </xsf:fragmentToInsert>
          </xsf:editWith>
       </xsf:xmlToEdit>
    </xsf:editing>

©2003-2004 Microsoft Corporation. All rights reserved. Permission to copy, display and distribute this document is available at: http://msdn.microsoft.com/library/en-us/odcXMLRef/html/odcXMLRefLegalNotice.asp