views:

57

answers:

1

On my page I have two AspxMenu.Click on Master Menu correspondent value will show on Child menu

XML syntax:

<Demo>
<ClientCompanyId CompanyId="1">
<MyMenu>
<module Text="Basic Settings" ModID="Mod1" ModuleID="1" MenuType="0" Perm="False">
<menu Text="Forms" MID="1-1" ParentID="Mod1" MenuDescription="Mod" ModuleID="1" MenuType="0" Perm="False">
<Leaf Text="LookUp" MID="1-3" ParentID="1" MenuDescription="" ModuleID="1" MenuType="0" Perm="False" LeafNode="true" TargetUrl="" ModuleMenuID="1-3">
</Leaf>
<submenu Text="Bank Branch" MID="1-4" ParentID="1" MenuDescription="" ModuleID="1" MenuType="0" Perm="False">
<Leaf Text="BO Category" MID="1-5" ParentID="4" MenuDescription="" ModuleID="1" MenuType="0" Perm="False" LeafNode="true" TargetUrl="" ModuleMenuID="1-5">
</Leaf>
</submenu>
</menu>
<menu Text="Reports" MID="1-2" ParentID="Mod1" MenuDescription="Mod" ModuleID="1" MenuType="0" Perm="False">
<Leaf Text="Cheque Type" MID="1-6" ParentID="2" MenuDescription="" ModuleID="1" MenuType="0" Perm="False" LeafNode="true" TargetUrl="" ModuleMenuID="1-6">
</Leaf>
<Leaf Text="Stock Exchange" MID="1-7" ParentID="2" MenuDescription="" ModuleID="1" MenuType="0" Perm="False" LeafNode="true" TargetUrl="" ModuleMenuID="1-7">
</Leaf>
</menu>
</module>
</MyMenu>
</ClientCompanyId></Demo>

MasterMenu fill and click Event:

 XDocument loaded = XDocument.Load(@"C:\Menu_Settings.xml");

            //XDocument loaded = XDocument.Load(@"C:\Menu_Settings.xml");

            var q = from c in loaded.Descendants("module")
                    where (int)c.Attribute("ModuleID") > 0
                    select new
                    {
                        Text = (string)c.Attribute("Text"),
                        ModID = (string)c.Attribute("ModID"),
                        ModuleID = (int)c.Attribute("ModuleID"),
                        MenuType = (int)c.Attribute("MenuType"),
                        Perm = (bool)c.Attribute("Perm")
                    };


            foreach (var name in q)
            {
                ASPxMasterMenu.RootItem.Items.Add(name.Text,name.ModuleID.ToString());


            } 

click on master Menu:

var r= ASPxMenu1.SelectedItem.Name;

            XDocument loaded = XDocument.Load(@"C:\Menu_Settings.xml");

            var q = from c in loaded.Descendants("menu")
                    where (int)c.Attribute("ModuleID") == Convert.ToInt32(ASPxMenu1.SelectedItem.Name)
                    select new
                    {
                        Text = (string)c.Attribute("Text"),
                        ModID = (string)c.Attribute("ModID"),
                        ModuleID = (int)c.Attribute("ModuleID"),
                        MenuType = (int)c.Attribute("MenuType"),
                        Perm = (bool)c.Attribute("Perm")
                    };


            foreach (var name in q)
            {
                AspxChildMenu.RootItem.Items.Add(name.Text);


            } 

in my XML under the module tag menu tag contains several leaf and submenu**tag i want to fill my **AspxChildMenu by those values.How to ?

A: 

try this out

var menu = from c in loaded.Descendants("menu")
                     where c.Attribute("ModuleID").Value == "1"
                     select c;

        var q = from c in menu.Descendants()
                where c.Name == "Leaf" || c.Name == "submenu"
                select new
                {
                    Text = (string)c.Attribute("Text"),
                    ModID = (string)c.Attribute("ModID"),
                    ModuleID = (int)c.Attribute("ModuleID"),
                    MenuType = (int)c.Attribute("MenuType"),
                    Perm = (bool)c.Attribute("Perm")
                };
Vinay B R