Skip to content

<Panel>

<Panel> is a container tag — like an HTML <div> — that groups related form content. Beyond layout, its main use is conditional rendering: show some controls only to administrators, or only when a particular field has a particular value.

Use ShowRoles to gate the panel by DNN security role, ShowIf to gate it by a runtime expression, or both — the panel renders only when both conditions pass.

Testing role-gated panels

When testing ShowRoles, log out of the host/superuser account first. Host accounts see all panels regardless of ShowRoles, so a panel can look correct in your testing and still be hidden from your real users.

Example — Show by role

html
<AddForm>
  ...
  <Panel ShowRoles="Editor">
    <Checkbox Id="chkApproved" DataField="Approved" DataType="Boolean" Text="Approved?" />
  </Panel>
  <table>
    <tr>
      <td>
        <Label For="txtFirstName" Text="First Name" />
        <TextBox Id="txtFirstName" DataField="FirstName" DataType="String" />
      </td>
    </tr>
    <tr>
      <td>
        <Label For="txtLastName" Text="Last Name" />
        <TextBox Id="txtLastName" DataField="LastName" DataType="String" />
      </td>
    </tr>
    <tr>
      <td colspan="2"><AddButton Text="Add" /> <CancelButton Text="Cancel" /></td>
    </tr>
  </table>
</AddForm>

Example — Show by URL parameter

html
<AddForm>
  ...
  <Panel ShowIf='[[Join("{0}=Kelly",[[Url:name]])]]'>
    <p>Welcome, Kelly!</p>
  </Panel>

  <AddButton Text="Add" /> <CancelButton Text="Cancel" />
</AddForm>

Properties

PropertyValuesDefaultDescription
IDstringUnique identifier for the panel
ShowRolescomma-listComma-delimited list of DNN role names. Panel renders only if the current user is in one of these roles
ShowIfexpressionExpression evaluated at render time. Panel renders only when the expression is true (since v4.7)
DefaultButtoncontrol idID of an <AddButton>, <UpdateButton>, or <CancelButton> "clicked" when the user presses Enter inside the panel
HorizontalAlignNotSet Left Center Right JustifyNotSetHorizontal alignment of content inside the panel
ScrollBarsNone Horizontal Vertical Both AutoNoneShow scrollbars when the panel's content overflows
WrapTrue FalseTrueWhen False, content does not wrap
BackImageUrlURLBackground image for the panel
AccessKeystringKeyboard shortcut character
CssClassstringCSS class name(s) for styling
StylestringInline CSS
HeightsizeHeight of the panel
WidthsizeWidth of the panel
VisibleTrue FalseTrueShows or hides the panel
Deprecated Properties

These properties use ASP.NET inline styling and are no longer recommended for modern web development. Use the CssClass property to apply CSS classes or the Style property for inline CSS instead.

PropertyValuesDescription
BackColorcolor name | #ddddddBackground color
BorderColorcolor name | #ddddddBorder color
BorderStyleNotSet None Dotted Dashed Solid Double Groove Ridge Inset OutsetBorder style
BorderWidthsizeBorder width
Font-BoldTrue FalseBold text
Font-ItalicTrue FalseItalic text
Font-NamesstringFont family name
Font-OverlineTrue FalseOverline text decoration
Font-SizeXX-Small X-Small Small Medium Large X-Large XX-Large or sizeFont size
Font-StrikeoutTrue FalseStrikethrough text decoration
Font-UnderlineTrue FalseUnderline text decoration
ForeColorcolor name | #ddddddText color

Property Details

  • ShowRoles: A comma-delimited list of DNN role names. The panel renders only when the current user belongs to at least one of the listed roles. The host/superuser account sees the panel regardless — log in as a regular user to test the gate.

  • ShowIf: A simple equality expression evaluated each time the panel renders. When the result is true, the panel renders; when false, it doesn't. Comparisons are text-only and case-insensitive. Use = for equality and <> for inequality.

    ShowIf and ShowRoles combine with AND semantics — when both are set, both must pass for the panel to render.

    html
    <Panel ShowIf="[[Country]] = US">
      <Label For="txtState" Text="State" />
      <TextBox Id="txtState" DataField="State" DataType="String" />
    </Panel>
  • DefaultButton: The Id of a button that should be clicked when the user presses Enter while focused inside the panel. Push-buttons (<AddButton>, <UpdateButton>, <CancelButton>) work reliably across browsers; link and image buttons may not.