If-then-clause in conditional

The "if-then" part of a conditional statement. This must be the first child of a <Choose> element, may be followed by any number of <When> siblings and one <Otherwise> sibling.

The contents of a <When> element specify what to execute and/or display if the condition holds; the optional <Otherwise> sibling specifies what to execute and/or display if no condition in any of the <When> elements holds.

LanguageCommand
ASP.NET Server Control<ugc:When runat="server">
JSP Custom Tag<ugc:When>
TCDL tag<tcdl:When>

Attributes

Attribute name (JSP or TCDL)Description
test (JSP or TCDL) or Test (ASP.NET)

The expression to evaluate; specifically, a comparison of context variables (pagecontext variables in JSP, or variables from HttpContext.Current.Items in .NET).

If the expression evaluates to true, the contents of this <When> element are executed and/or displayed; otherwise, all sibling <When> elements are evaluated (if any). If none of the conditions in any of the <When> elements hold, the contents of the <Otherwise> sibling element are executed and/or displayed, or if no <Otherwise> element exists, nothing happens.