New to Telerik UI for ASP.NET MVC? Start a free 30-day trial
Open Window from Menu Item Click by Using Ajax
Environment
Product | Telerik UI for ASP.NET MVC Menu |
Product Version | Created with version 2024.4.1112 |
Description
How can I use a Telerik UI for ASP.NET MVC Menu item click to open a Telerik UI for ASP.NET MVC Window?
Solution
- Declare the Menu component.
- Handle the
Select
event of the Menu. - In the event handler, get the
id
attribute of the current item. - Conditionally check if the
id
is the expected one (openWindow). - Implement an Ajax request to an Action Method, which is specified in the Menu item.
- In the Action Method, return a Partial View with the Window.
Razor
@{Html.Kendo().Menu()
.Orientation(MenuOrientation.Horizontal)
.Name("applicationMenu")
.Items(menu => menu.Add().Text("Home").Items(homeMenu =>
{
homeMenu.Add().Text("Show Window").Action("RenderWindow", "Home").HtmlAttributes(new { id = "openWindow" });
}))
.Events(e => e.Select("onSelect"))
.Render();
}
For the complete implementation of the suggested approach, refer to the ASP.NET MVC project on how to open a Window when a specified Menu item is clicked.