From Sense/Net Wiki
Jump to: navigation, search
  • 100%
  • 6.0
  • Enterprise
  • Community
  • Planned


The ContextInfo control is a user control that supplies a context Content according to set parameters. It is useful when the control or page contains multiple controls that rely upon the same context.


The following controls use the ContextInfo control:

See example usage in example section.


  • Selector: this property defines the selected Content. Controls the path to be returned with the Path property. Possible values:
    • <EMPTY>: if Selector is not set (or set to anything but the following), path of the current context will be returned.
    • currentuser: path of the current user is returned.
    • currentsite: returns the path of the site containing the current context Content.
    • currentlist: returns the path of the list containing the current context Content.
    • currentworkspace: returns the path of the current workspace.
    • currentapplicationcontext: returns the path of the current Application if it is the requested node. If it's not applicable (the current context is not an Application) and the ReplaceNullWithContext is set to true the current context Content path is returned.
    • currenturlcontent: returns the Content path selected by the context url parameter.
  • UsePortletContext: if set to true the control will use the containing Context Bound Portlet's settings to get the context Content. This Content will then be used by the Selector property. If set to false the page's current context Content is used as context. Default is false.
  • ReplaceNullWithContext: affects returned path when currentapplicationcontext is selected with Selector property (see above). Default is false.
  • Path: (only getter) this property is used by controls to obtain the resolved context Content path.

If the selected context Content cannot be resolved, empty string is returned in the Path property.


The following is an example on how to use the ContextInfo control with an ActionLinkButton control:

   <sn:ContextInfo runat="server" Selector="CurrentContext" UsePortletContext="true" ID="myContext" />
   <sn:ActionLinkButton ID="ActionLinkButton1" runat="server" IconUrl="/Root/Global/images/icons/16/edit.png" ActionName="Edit" 
Text="Edit" ContextInfoID="myContext" />

Minimal example: selects the current context:

   <sn:ContextInfo runat="server" ID="newWS" />

This next example selects the current user:

   <sn:ContextInfo runat="server" Selector="CurrentUser" UsePortletContext="false" ID="myContext" />

The following lines of code show an example for how to create custom controls that use a ContextInfo control:

   var context = UITools.FindContextInfo(this, ContextInfoID);
   var path = context == null ? string.Empty : context.Path;

Related links