Is there any way to get a dynamic menu for Asp.Net web application using JSON Object or XML Data?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes why not. Set the datasource of the asp.net menu to the xml coming from the source.
Lets create this menu in few steps.
In web application add a XML file named menu.xml. The Xml Code as follow as
<?xml version="1.0" encoding="utf-8" ?>
<HomePage>
<Menu text="Issue1" url="Issue1.aspx">
<SubMenu text="Concept1" url="Concept1.aspx"></SubMenu>
<SubMenu text="Concept2" url="Concept2.aspx"></SubMenu>
<SubMenu text="Concept3" url="Concept3.aspx"></SubMenu>
</Menu>
<Menu text="Issue2" url="Issue2.aspx">
<SubMenu text="Problem1" url="Problem1.aspx"></SubMenu>
<SubMenu text="Problem2" url="Problem2.aspx"></SubMenu>
<SubMenu text="Problem3" url="Problem3.aspx"></SubMenu>
</Menu>
</HomePage>
Add the XMLDataSource Control to the page from the Data tab of the Toolbox.
Link the DataSourceID as XmlDataSource1 for the Menu control and the menu.xml as DataFile of XmlDataSource control and bind the menu control.
The code for menu control is
The code for XmlDataSource is
Here I am using XML File , you can also use dynamic xml instead of the static xml.