I figure out a simpler way!
The concept is as follows:
1. When the user clicks on the first menu, save the Menu1.SelectedItem reference into a session or something.
2. When the user clicks on the second menu, set the saved reference selected property to true
but for some reasons I was not able to save an object reference so I had to tweak the approach:
1. When the user clicks on the first menu, save the Menu1.SelectedItem.DataPath (or the index count of the selected item) into a session. or something such as lastTopMenuItemDataPath
2. When the user clicks on the second menu, select the menu item from the first menu that matches the first menu.
Having said the solution, here is the code:
For the master page:
<asp:Menu ID="Menu2" runat="server" DataSourceID="SiteMapDataSource2" MaximumDynamicDisplayLevels="0">
<StaticMenuItemStyle CssClass="menuItem" />
<StaticSelectedStyle CssClass="menuItemSelected" />
<StaticHoverStyle CssClass="menuItemHover" />
</asp:Menu>
<asp:SiteMapDataSource ID="SiteMapDataSource2" runat="server" ShowStartingNode="false" StartingNodeOffset="1" />
<asp:Menu ID="Menu1" OnPreRender="setRef" runat="server" DataSourceID="SiteMapDataSource1" MaximumDynamicDisplayLevels="0" Orientation="Horizontal">
<StaticMenuItemStyle CssClass="menuItem" />
<StaticSelectedStyle CssClass="menuItemSelected" />
<StaticHoverStyle CssClass="menuItemHover" />
</asp:Menu>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="false" />
<asp:ContentPlaceHolder OnPreRender="getRef" ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
The master page code behind:
public partial class MasterPage : System.Web.UI.MasterPage {
protected void setRef(object sender, EventArgs e) {
if (Menu1.SelectedItem != null) Session["lastTopMenuItemDataPath"] = Menu1.SelectedItem.DataPath;
}
protected void getRef(object sender, EventArgs e) {
string ldp = Session["lastTopMenuItemDataPath"].ToString();
if(ldp !=null) foreach (MenuItem m in Menu1.Items) m.Selected = (m.DataPath == ldp);
}
}