The settings of the XML can be used to set up the page and jump between pages.
This example reads the data from the XML and then binds to the control, which can be used to jump between pages based on the URL of the content being read.
1, the first need to write XML. For example:
Menu.xml--->
<?xml version= "1.0" encoding= "Utf-8"?> <Menu> <!--<TopMenu> <menuitem name= "Listairline" Description= "Basic Management" url= "/backstage/basicmanagement/management.aspx"/> <menuitem Name= "ListOrders" description= "Order Management" url= "/backstage/ordermanagement.html"/> <menuitem name= "Listinternaluser" Description= " Background user Management "Url="/backstage/internalusermanagement/management.aspx "/> </TopMenu>-->
<topmenu name= "Basedata" description= "Basic Management" url= "/backstage/basicmanagement/management.aspx" > <subtitle title= "Basic Management" > <leftmenuitem name= "Basedata_airline" description= "domestic route" url= "/backstage/" Basicmanagement/management.aspx? Type=airline "/> <leftmenuitem name=" Basedata_airlineint "description=" International Route "url="/backstage/basicmanagement/management.aspx? Type=airlineint "/> <leftmenuitem name=" Basedata_aircompany "description=" Airline "url="/backstage/basicmanagement/management.aspx? Type=aircompany "/> <leftmenuitem name=" Basedata_airport "description=" Airport Management "Url="/backstage/basicmanagement/management.aspx? Type=airport "/> <leftmenuitem name= "Basedata_plane" Description= "Aircraft Information" Url= " /backstage/basicmanagement/management.aspx? Type=plane "/> <leftmenuitem name=" Basedata_favortype "description=" offer Information "Url="/backstage/basicmanagement/management.aspx? Type=favortype "/> </SubTitle> </topmenu ></Menu>
2. It is necessary to put the written menu.xml in Web. config to facilitate its invocation
<appSettings>
<add key= "Menuconfig" value= "/configuration/menu/menu.xml"/>
</appSettings>
3. menu.xml files can be obtained by ConfigurationManager
public static ienumerable<dynamic> Getmainmenus ()
{
String path = configurationmanager.appsettings["Menuconfig"];
Path = HttpContext.Current.Server.MapPath (path);
var xElement = xelement.load (path). Elements ("Topmenu");
var xelements = xElement as ilist<xelement>?? Xelement.tolist ();
if (Xelements.any ())
{
var menuconfig = from P in xelements
Select P;
var menus = new list<dynamic> ();
foreach (Var menu in Menuconfig)
{
Menus. Add (New {Name = menu. Firstattribute.value, Description = menu. Attribute ("Description"). Value, Url = menu. Attribute ("Url"). Value});
}
return menus;
}
return null;
}
4. Bind the read-out data to the appropriate control
Menulist.datasource = menus;
Menulist.databind ();
Because the <a href> property is in the bound ListView, the URL that is given the corresponding bound value jumps directly. The code is as follows:
<asp:listview runat= "Server" id= "Menulist" >
<ItemTemplate>
<li id= ' <% #Eval ("Name")%> ' ><a href= ' <% #Eval ("Url")%> ' >
<% #Eval ("Description")%></a> </li>
</ItemTemplate>
</asp:ListView>
PS: <% #Eval ()%> the value to reach the bound field
Manipulating Web pages with XML