ASP. net2.0 menu control makes drop-down navigation menu

Source: Internet
Author: User

Steps:

1. xml file. Here we use the XML document: slivermenu. XML to describe the specific menu content. For example

<? XML version = "1.0" encoding = "UTF-8"?>
<Items>
<Menuitem navigateurl = "http // DOTNET. X. CC/" text = "">
<Menuitem navigateurl = "http // DOTNET. X. CC/showlist. X? Id = 1 "text =" News notification ">
<Menuitem navigateurl = "classical. X" text = "News 1"/>
<Menuitem navigateurl = "Rock. X" text = "News 2">
<Menuitem navigateurl = "classical. X" text = "Latest news 2.1"/>
<Menuitem navigateurl = "classical. X" text = "Latest news 2.2"/>
</Menuitem>
</Menuitem>
<Menuitem navigateurl = "movies. X" text = "subject Introduction">
<Menuitem navigateurl = "Action. X" text = "Notification 1"/>
<Menuitem navigateurl = "drama. X" text = "Notice 2"/>
<Menuitem navigateurl = "musical. X" text = "Notice 3"/>
</Menuitem>
<Menuitem navigateurl = "" text = "">

</Menuitem>
<Menuitem navigateurl = "" text = "">

</Menuitem>
<Menuitem navigateurl = "" text = "">

</Menuitem>
<Menuitem navigateurl = "" text = "">

</Menuitem>
<Menuitem navigateurl = "" text = "">

</Menuitem>
<Menuitem navigateurl = "" text = "">

</Menuitem>
<Menuitem navigateurl = "" text = "Download column">

</Menuitem>
<Menuitem navigateurl = "" text = "BBS">

</Menuitem>
</Menuitem>
</Items>

2. Add the xmldatasource control and configure the Data source: slivermenu. xml.

3. Add the menu control. Configure the data source xmlperformance1.

4. Data Binding. On the Properties panel of menu1, select databinding, click menuitem, and add it to "selected data binding". In the data binding dialog box on the right, select textfield and navigatrurlfield. Click "OK ".

5. On the menu control properties panel, select orientation: horizontal.

OK. The Code is as follows:

 

<% @ Page Language = "C #" autoeventwireup = "true" codefile = "slivermenu. aspx. cs" inherits = "slivermenu" %>

<! 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 runat = "server">
<Title> slivermenu </title>
</Head>
<Body>
<Form ID = "form1" runat = "server">
& Nbsp;
<Asp: xmldatasource id = "xmlperformance1" runat = "server" datafile = "~ /App_data/staticmenu. xml"
XPath = "items/menuitem" ontransforming = "xmlperformance=transforming"> </ASP: xmldatasource>
<Asp: menu id = "menu1" runat = "server" performanceid = "xmlperformance1" dynamichorizontaloffset = "17"
Font-bold = "true" font-size = "small" maximumdynamicdisplaylevels = "2" orientation = "horizontal"
Staticdisplaylevels = "2" style = "position: relative">
<Databindings>
<Asp: menuitembinding datamember = "menuitem" navigateurlfield = "navigateurl" textfield = "text"/>
</Databindings>
</ASP: menu>
</Form>
</Body>
</Html>

 

 

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.