Load menu panel from controller

  1. #1

    Load menu panel from controller

    Hello,
    I would like to load MenuPanel from controller I had this JavaScript error :
    invalid object initializer
    This is my action :
     public ContentResult LoadPanelContent(string containerID)
            {
                ContentResult cr = new ContentResult();
                MenuPanel b = new MenuPanel();
                b.ID = "Mp1";
                b.Height = 300;
                b.Width = 185;
                b.Title = "Menu";
                cr.Content = string.Format("<script>{0}</script>", b.ToScript(RenderMode.AddTo, containerID));
                return cr;
            }
    This is my view page :
    <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Home</title>
    </head>
    <body>
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:Viewport runat="server">
            <Items>
                <ext:Panel ID="_pnl" runat="server" Title="test">
                    <AutoLoad Url="/View/LoadPanelContent">
                        <Params>
                            <ext:Parameter Name="containerID" Value="#{_pnl}" Mode="Value" />
                        </Params>
                    </AutoLoad>
                </ext:Panel>
            </Items>
        </ext:Viewport>
    </body>
    </html>
  2. #2
    Done :) Solved we should implement some think like this in the action :
    public ContentResult LoadPanelContent(string containerID)
            {
                ContentResult cr = new ContentResult();
                MenuPanel b = new MenuPanel();
                b.ID = "Mp1";
                b.Height = 300;
                b.Width = 185;
                b.Title = "Menu";
                b.Menu.Add(new MenuItem("Item1")); //new line added
                b.Menu.Add(new MenuItem("Item2")); //new line added
                
                cr.Content = string.Format("<script>{0}</script>", b.ToScript(RenderMode.AddTo, containerID));
                return cr;
            }
    Last edited by wadhah; Oct 28, 2011 at 5:40 PM.

Similar Threads

  1. Replies: 1
    Last Post: Jul 02, 2012, 6:19 PM
  2. Load Panel from MVC Controller
    By stu in forum 2.x Help
    Replies: 1
    Last Post: Jun 18, 2012, 11:26 PM
  3. [CLOSED] [Razor] TreePanel load nodes from controller action
    By boris in forum 2.x Legacy Premium Help
    Replies: 8
    Last Post: May 18, 2012, 9:43 AM
  4. Replies: 2
    Last Post: Apr 02, 2012, 7:48 AM
  5. how to load data to grid panel in page load
    By andylaiyongsing in forum 1.x Help
    Replies: 1
    Last Post: Apr 16, 2010, 10:27 AM

Posting Permissions