This nice article explains how to synchronize two menus. In my case i put one horizontal and the other vertical but I am stuck in a very simple task (I am a beginner)
how do I make it to navigate to the mapped page when clicking the second menu? I realize that that is the way is supposed to work because at the end of the article it says that it catches the click event instead of navigating to any location:
The preceding code catches the click event of Menu1. Instead of navigating to any location, you use the value to determine what the second Menu control displays. You accomplish that by adjusting the StartingNodeUrl property of the second Menu control's SiteMapDataSource control.
I tweaked a little bit the code but don't know if that's the cause.
I want to either navigate to an aspx page or load a control into the content placeholder in Default.aspx when clicking an item from the second menu.
Please help
Here are the files:
Web.sitemap
1 <?xml version="1.0" encoding="utf-8" ?>
2 <
siteMap>
3 <
siteMapNode title="ROOT">
4 <
siteMapNode title="Browse Projects">
5 <
siteMapNode title="Search" url="searchProjects.aspx"/>
6 <
siteMapNode title="View Workflows" url="viewWorkflows.aspx"/>
7 <
siteMapNode title="View Projects" url="viewProjects.aspx"/>
8 <
siteMapNode title="View Teams" url="viewTeams.aspx"/>
9 </
siteMapNode>
10 <
siteMapNode title="Manage Projects">
11 <
siteMapNode title="Enter new Project" url="Pages/newProject.aspx"/>
12 <
siteMapNode title="Enter new Workflow" url="Pages/newWorkflow.aspx"/>
13 </
siteMapNode>
14 <
siteMapNode title="My GKD">
15 <
siteMapNode title="My Projects" url="myProjects.aspx"/>
16 <
siteMapNode title="Edit Profile" url="myProfile.aspx"/>
17 </
siteMapNode>
18 </
siteMapNode>
19 </
siteMap>
MasterPage.master.cs
1 using System;
2 using System.Data;
3 using System.Configuration;
4 using System.Collections;
5 using System.Web;
6 using System.Web.Security;
7 using System.Web.UI;
8 using System.Web.UI.WebControls;
9 using System.Web.UI.WebControls.WebParts;
10 using System.Web.UI.HtmlControls;
11
12 public partial class MasterPage : System.Web.UI.MasterPage {
13 protected void Menu_Top_MenuItemClick(object sender, MenuEventArgs e) {
14 {
15 switch (e.Item.Value) {
16 case "Browse Projects":
17 SiteMapDataSourceGKD2.StartingNodeUrl = "searchProjects.aspx";
18 return;
19 case "Manage Projects":
20 SiteMapDataSourceGKD2.StartingNodeUrl = "Pages/newProject.aspx";
21 return;
22 case "My GKD":
23 SiteMapDataSourceGKD2.StartingNodeUrl = "myProjects.aspx";
24 return;
25 }
26 }
27 }
28 protected void Menu_Left_MenuItemClick(object sender, MenuEventArgs e) {
29 MenuItem m = Menu_Left.SelectedItem;
30 string tmp = "<li>" + m.Target +
31 "<li>" + m.NavigateUrl +
32 "<li>" + m.Value +
33 "<li>" + m.parent +
34 "<li>" + m.Value +
35 "<li>" + m.ValuePath;/* +
36 "<li>" + m.Parent.NavigateUrl +
37 "<li>" + m.Parent.Target +
38 "<li>" + m.Parent.Value;
39 */
40 contentPlaceHolder.Controls.Add(new LiteralControl(tmp));
41
42 //Response.Write(tmp);
43 //Response.Redirect();
44 }
45 }
MasterPage.master
1 <%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
2
3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
5 <html xmlns="http://www.w3.org/1999/xhtml" >
6 <head runat="server">
7 <title>GKD Geochemical Knowledge Desktop</title>
8 <link href="css_gks/Master.css" rel="stylesheet" type="text/css" />
9 </head>
10 <body style="margin:0;height:100%">
11 <form id="form1" runat="server">
12 <table id="masterViewPort" cellpadding="0";cellspacing="0" border="0">
13 <tr>
14 <td colspan="3" style="background-image: url(img_gks/banner_back.gif); height: 20px; color:#fff; font-weight: bold; font-size: small; width: 100%; text-align: right;">
15 Geochemical Knowledge Desktop Ver 2007.07.23 [Development]
16 </td>
17 </tr>
18 <tr>
19 <td style="height:100%; vertical-align: top; background-color: #e7efff; border-right: #d7e1f6 1px solid; text-align: center;">
20 <div style="width: 100%; height: 77px; background-color: #336699; text-align: center; font-size: x-small; vertical-align: text-bottom; color: white;">
21 <img align="top" src="img_gks/ou_logo_global40.gif" style="margin: 5px;" /><br />
22 GKD Guest User
23 <br />
24 @ houic-s-604</div>
25
26 <asp:Menu ID="Menu_Left" runat="server" CssClass="topMenu" Height="40px" ItemWrap="True" StaticEnableDefaultPopOutImage="False" DataSourceID="SiteMapDataSourceGKD2" Width="100%" MaximumDynamicDisplayLevels="0" OnMenuItemClick="Menu_Left_MenuItemClick">
27 <StaticMenuItemStyle BorderStyle="Outset" BorderWidth="1px" Height="40px" BackColor="#D7E1F6" HorizontalPadding="10px" />
28 <StaticSelectedStyle BackColor="#336699" BorderStyle="Inset" Font-Bold="True" ForeColor="White" BorderWidth="1px" />
29 <DataBindings>
30 <asp:MenuItemBinding DataMember="SiteMapNode" TextField="Title" />
31 </DataBindings>
32 <Items>
33 <asp:MenuItem Text="My GKD" Value="My GKD"></asp:MenuItem>
34 <asp:MenuItem Text="Administration" Value="Administration"></asp:MenuItem>
35 <asp:MenuItem Text="Browse Database" Value="Browse Database"></asp:MenuItem>
36 <asp:MenuItem Text="Logout" Value="Logout"></asp:MenuItem>
37 </Items>
38 <StaticHoverStyle BackColor="#E0E0E0" BorderStyle="Inset" Height="40px" ForeColor="Black" />
39 </asp:Menu>
40 </td>
41 <td colspan="2" style="vertical-align:top; width: 100%;">
42 <div style="background-color: #e7efff; border-bottom: #d7e1f6 1px solid;">
43 <img src="img_gks/tmenu_square_fade.gif" align="right" /><asp:Menu ID="Menu_Top" runat="server" CssClass="topMenu" ItemWrap="True" StaticEnableDefaultPopOutImage="False" DataSourceID="SiteMapDataSourceGKD" MaximumDynamicDisplayLevels="0" OnMenuItemClick="Menu_Top_MenuItemClick" Orientation="Horizontal">
44 <StaticMenuItemStyle BorderStyle="Outset" BorderWidth="1px" Height="40px" BackColor="#D7E1F6" HorizontalPadding="10px" />
45 <StaticSelectedStyle BackColor="#336699" BorderStyle="Inset" Font-Bold="True" ForeColor="White" BorderWidth="1px" />
46 <DataBindings>
47 <asp:MenuItemBinding DataMember="SiteMapNode" TextField="Title" />
48 </DataBindings>
49 <Items>
50 <asp:MenuItem Text="My GKD" Value="My GKD"></asp:MenuItem>
51 <asp:MenuItem Text="Administration" Value="Administration"></asp:MenuItem>
52 <asp:MenuItem Text="Browse Database" Value="Browse Database"></asp:MenuItem>
53 <asp:MenuItem Text="Logout" Value="Logout"></asp:MenuItem>
54 </Items>
55 <StaticHoverStyle BackColor="#E0E0E0" BorderStyle="Inset" Height="40px" ForeColor="Black" />
56 </asp:Menu>
57 </div>
58 <asp:ContentPlaceHolder runat="server" ID="contentPlaceHolder">
59 </asp:ContentPlaceHolder></td>
60 </tr>
61 </table>
62 <asp:SiteMapDataSource ID="SiteMapDataSourceGKD" runat="server" ShowStartingNode="False" />
63 <asp:SiteMapDataSource ID="SiteMapDataSourceGKD2" runat="server" ShowStartingNode="False"
64 StartingNodeOffset="-1" StartingNodeUrl="~/Default.aspx" />
65 </form>
66 </body>
67 </html>
68
Default.aspx
1 <%@ Page MasterPageFile="~/MasterPage.master" Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
2 hello world