Load menu dinamically on ASP.NET

1 posts, 0 answers
  1. Nick
    Nick avatar
    15 posts
    Member since:
    Nov 2007

    Posted 10 Oct 2014 Link to this post

    Hi guys, I just wanted to share this code in case anyone need it, because I didn't find nothing similar on the forum.

    This example loads a kendo menu dinamically from an aspx page, getting the elements from a server method accessed by ajax

    .cs file

     [WebMethod(EnableSession = false)]
            public static string GetToolsAdminProjects()
                List<Project> toolsAdminProjectList = ProjectsHelper.GetToolsAdminProjectList();
                List<ContextMenuItem> result = toolsAdminProjectList.Select(e=> new ContextMenuItem
                    text = e.DisplayName,
                    url = e.URL

                var serializer = new JavaScriptSerializer();
                string json = serializer.Serialize(result);
                return json;

    .aspx file 
    <script type="text/javascript">

                     type: "POST",
                     url: "GridView.aspx/GetToolsAdminProjects",
                     data: "{}",
                     contentType: "application/json",
                     dataType: "json",
                     success: function (result) {
                         var d = jQuery.parseJSON(result.d)
                         var menu = $("#menu").data("kendoMenu");


Back to Top