Asp. The application of the menu control in net and the XmlDataSource of the knowledge _ practical skills

Source: Internet
Author: User
Previously always thought that the menu is made through Sitemap, recently saw the project in the method is to use the XmlDataSource list set.
MENUSITE.XLM file:
Copy Code code as follows:

<?xmlversion= "1.0" encoding= "Utf-8"?>
<menusvalue= "" >
<topmenuid= "value=" "Imageurl=" ~/app_themes/public/images/publicimages/topmenu_stl.jpg "NavigateUrl=" " >
<topmenuitemid= "value=" Applyforshorttermleaseofstateland "navigateurl=" ~/tol/issuance/ Apptolapplication.aspx "></TopMenuItem>
<topmenuitemid= "102" value= "Managemyexistingaccount" navigateurl= "~/caseenquiry/homeauthenticate.aspx"? Showpanel=true "></TopMenuItem>
<topmenuitemid= "value=" viewmessagesformyapplications "navigateurl=" ~/commonutility/email/ Listappcorrespondence.aspx "></TopMenuItem>
</TopMenu>
<topmenuid= "value=" "Imageurl=" ~/app_themes/public/images/publicimages/topmenu_aosl.jpg "NavigateUrl=" " >
<topmenuitemid= "value=" Managemyexistingstatetitle "navigateurl=" "></TopMenuItem>
<topmenuitemid= "203" value= "viewmessagesformyapplications" "Navigateurl=" "></TopMenuItem>
</TopMenu>
<topmenuid= "value=" "Imageurl=" ~/app_themes/public/images/publicimages/topmenu_lup.jpg "NavigateUrl=" " >
<topmenuitemid= "value=" Submitproposalforlanduse "navigateurl=" "></TopMenuItem>
</TopMenu>
<topmenuid= "value=" "Imageurl=" ~/app_themes/public/images/publicimages/topmenu_logout.jpg "NavigateUrl=" ~ "Logout.aspx" >
</TopMenu>
</Menus>

Create XmlDataSource and Asp:menu controls in HTML:
Copy Code code as follows:

<asp:xmldatasourceid= "XmlDataSource1" runat= "Server" datafile= "Menusite.xml" ></asp:XmlDataSource>
<asp:menudatasourceid= "XmlDataSource1" runat= "Server" id= "Menu1" maximumdynamicdisplaylevels= "4"
orientation= "Horizontal" staticdisplaylevels= "2" staticenabledefaultpopoutimage= "False"
Dynamicenabledefaultpopoutimage= "false" staticsubmenuindent= "" itemwrap= "True" >
<DataBindings>
<asp:menuitembindingdatamember= "Topmenu" imageurlfield= "ImageUrl" textfield= "value"
Navigateurlfield= "NavigateUrl" valuefield= "value"/>
<asp:menuitembindingdatamember= "Topmenuitem" navigateurlfield= "NavigateUrl" textfield= "value"
valuefield= "Value"/>
<asp:menuitembindingdatamember= "Menus" textfield= "value" valuefield= "value"/>
</DataBindings>
</asp:Menu>

menu is really comprehensive enough to set properties to meet your requirements without any code:
MaximumDynamicDisplayLevels: Specifies the number of dynamic display menu node layers that should be displayed after the static display layer. If set to 0, the child nodes will not display dynamic.
Orientation: Use to set a horizontal menu bar on the page.
StaticDisplayLevels: The number of layers of the menu that is displayed statically from the root menu. The trick here is that XML must have a root node, but when the menu is displayed, the second level of the menu item is displayed, so this
The root node value of the XML is set to NULL, and then saticdisplayleves to 2 so that the user sees the second level of static display.
Staticenabledefaultpopoutimage: The static menu item defaults to display with a small arrow, set to False, to modify this state.
Dynamicenabledefaultpopoutimage: Set whether dynamic display with small arrows.
Staticsubmenuindent: Controls show the indentation depth of submenu entries, if these menu levels are set to display in static mode.
Itemwrap: Sets whether the menu item can be wrapped.
The above settings make it easy to create the desired menu style.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.