---
title: Displaying context menus in transformations
related:
  - https://docs.kentico.com/k12sp/developing-websites/loading-and-displaying-data-on-websites/writing-transformations/creating-transformations-for-pages.md
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

When writing transformations for displaying [Users](https://docs.kentico.com/k12sp/managing-users.md) or [Groups](https://docs.kentico.com/k12sp/community-features/groups.md), you can enclose the transformation into a container control that provides a context menu triggered by right-clicking a user or group.

> **Note:** **Note**: You can only add controls into transformations of the **ASCX** type. The system does not render context menu controls in the other transformation types.

## Writing transformations for user context menus

To add the context menu to lists of users, enclose your transformation inside the **cms:usermenucontainer** control ([edit the transformation](https://docs.kentico.com/k12sp/developing-websites/loading-and-displaying-data-on-websites/writing-transformations/creating-transformations-for-pages.md#editing-transformations) used by the component that displays the list of users):

```html

<cms:usermenucontainer runat="server" ID="userMenuElem" MenuID="userContextMenu" Parameter='<%# Eval("UserID").ToString() %>' ContextMenuCssClass="UserContextMenu" >

... transformation code ...

</cms:usermenucontainer>

```

## Writing transformations for group context menus

To add the context menu to lists of groups, you need to enclose your transformation inside the **cms:groupmenucontainer** control ([edit the transformation](https://docs.kentico.com/k12sp/developing-websites/loading-and-displaying-data-on-websites/writing-transformations/creating-transformations-for-pages.md#editing-transformations) used by the component that displays the list of groups):

```html

<cms:groupmenucontainer runat="server" ID="groupMenuElem" MenuID="groupContextMenu" Parameter='<%# Eval("GroupID").ToString() %>' ContextMenuCssClass="UserContextMenu" >

... transformation code ...

</cms:groupmenucontainer>

```

## Modifying the context menu design

The default controls used for context menus are stored in **\CMSAdminControls\ContextMenus**:

- **GroupContextMenu.ascx**
- **UserContextMenu.ascx**

These two controls are used automatically for the Group or User context menus. If you want to modify the design of the context menus, edit the controls in Visual Studio.

You can also develop custom context menu controls. In this case, you need to add the **MenuControlPath** parameter to the _cms:usermenucontainer_ or _cms:groupmenucontainer_ controls in the transformation and set its value to the path to your control:

```html

<cms:groupmenucontainer runat="server" ID="groupMenuElem" MenuID="groupContextMenu" Parameter='<%# Eval("GroupID").ToString() %>' ContextMenuCssClass="UserContextMenu" MenuControlPath="~\CMSAdminControls\ContextMenus\MyGroupContextMenu.ascx" >

... transformation code ...

</cms:groupmenucontainer>

```
