CodeVerge.Net Beta


   Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: Date Entered: 8/7/2007 7:52:56 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 6 Views: 342 Favorited: 0 Favorite
7 Items, 1 Pages 1 |< << Go >> >|
"jleviaguirre"
NewsGroup User
master page with two menus, content place holder, sitemap and dynamic controls8/7/2007 7:52:56 PM

0

Dear all,

I have a master page with two menus. In fact, I want both menus to remain selected after I pick an item from the second menu.

When I click the first menu, the second menu populates from my web.sitemap but when I click the second menu, the pages "reloads" and looses the selections in both menus. If i click the first menu item again, then the page works as intended.

How can I programatically click the selected item from the top menu? Is that the right solution? I am planning to add some controls into the contentplaceholder dynamically driven from the second menu.


If you run my code, you will understand what I am talking about. 

I posted all my code here

the relevant lines of code are here: 

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>Untitled Page</title>
8        <link href="css_gks/Master.css" rel="stylesheet" type="text/css" />
9    </head>
10   <body>
11       <form id="form1" runat="server">
12           <table border="0" cellpadding="0" cellspacing="0" style="width: 100%; height: 100%">
13               <tr>
14                   <td colspan="2" style="height: 1px">
15                       <asp:Menu ID="Menu1" runat="server" CssClass="topMenu" DataSourceID="SiteMapDataSource1"
16                           MaximumDynamicDisplayLevels="0" OnMenuItemClick="Menu1_MenuItemClick" Orientation="Horizontal">
17                           <DataBindings>
18                               <asp:MenuItemBinding DataMember="SiteMapNode" TextField="Title" />
19                           </DataBindings>
20                           <StaticMenuItemStyle BackColor="#D7E1F6" BorderStyle="Outset" CssClass="menuItem" />
21                           <StaticSelectedStyle BackColor="#336699" BorderStyle="Inset" CssClass="menuItem"
22                               ForeColor="White" />
23                           <StaticHoverStyle BackColor="#E0E0E0" BorderStyle="Inset" CssClass="menuItem" />
24                       </asp:Menu>
25                   </td>
26               </tr>
27               <tr>
28                   <td style="vertical-align: top; width: 1px;">
29                       <asp:Menu ID="Menu2" runat="server" DataSourceID="SiteMapDataSource2">
30                           <StaticMenuItemStyle BackColor="#D7E1F6" BorderStyle="Outset" CssClass="menuItem" />
31                           <StaticSelectedStyle BackColor="#336699" BorderStyle="Inset" CssClass="menuItem"
32                               ForeColor="White" />
33                           <StaticHoverStyle BackColor="#E0E0E0" BorderStyle="Inset" CssClass="menuItem" />
34                       </asp:Menu>
35                   </td>
36                   <td valign="top">
37           <asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
38           </asp:contentplaceholder>
39                   </td>
40               </tr>
41           </table>
42           <asp:SiteMapDataSource ID="SiteMapDataSource2" runat="server" ShowStartingNode="False"
43               StartingNodeOffset="-1" StartingNodeUrl="gkd.aspx?ctx=srch" />
44           <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="False" />
45       </form>
46   </body>
47   </html>
48   
   
1        protected void Menu1_MenuItemClick(object sender, MenuEventArgs e) {
2            switch (e.Item.Value) {
3                case "Browse Projects":
4                    SiteMapDataSource2.StartingNodeUrl = "gkd.aspx?ctx=srch";
5                    break;
6                case "Manage Projects":
7                    SiteMapDataSource2.StartingNodeUrl = "gkd.aspx?ctx=npj";
8                    break;
9                case "My GKD":
10                   SiteMapDataSource2.StartingNodeUrl = "gkd.aspx?ctx=mypjs";
11                   break;
12           }
13   
 
"Android" <>
NewsGroup User
Re: master page with two menus, content place holder, sitemap and dynamic controls8/9/2007 3:43:08 PM

0

Did you manage to solve this one? If not, I have a potential solution for you. You could use a MultiView control to give the impression that separate sub-pages are being opened. Not ideal, I know, but at least it leaves the top level selection active.

"jleviaguirre"
NewsGroup User
Re: master page with two menus, content place holder, sitemap and dynamic controls8/10/2007 4:28:57 PM

0

No, I was not able to. I had to remove the databindings from the menus. Only the last menu item remains selected. I guess the solution is to add extra code to climb up the selected item all the way to the root and select it (apply the selected style)

 Another approach is to do it via javascript but I will try the first aproach.
 

"Amanda Wang -
NewsGroup User
Re: master page with two menus, content place holder, sitemap and dynamic controls8/13/2007 4:31:49 AM

0

Hi,

You can try to use microsoft's CSS Menu Adapter of the ASP.NET 2.0 CSS Friendly Control Adapters collection, it is much more flexible then the Standar menu control.

 

Hope it helps.


Please remember to mark the replies as answers if they help and unmark them if they provide no help.


Yours sincerely,
Amanda Wang
Microsoft Online Community Support
"Android" <>
NewsGroup User
Re: master page with two menus, content place holder, sitemap and dynamic controls8/13/2007 9:50:02 AM

0

I'm already using that, but thanks for the suggestion. I may have to abandon the Menu control and SiteMap. Instead, I think I may have to hard-wire my navigation buttons. Not as flexible, but OK if my site structure remains stable (which it will).

"Android" <>
NewsGroup User
Re: master page with two menus, content place holder, sitemap and dynamic controls8/16/2007 10:17:00 AM

0

I don't know if you're still struggling with this, but I recently came across this post, which has solved the problem for me.

"jleviaguirre"
NewsGroup User
Re: master page with two menus, content place holder, sitemap and dynamic controls8/23/2007 4:37:18 PM

0

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);
    }
}
 
7 Items, 1 Pages 1 |< << Go >> >|


Free Download:













build error

combining aspnetdb and club

require login to access files

login attempt was not successful error for disabled users

errors on the links page

sqldatasource - not able to specify insert, update and delete

admin link in master

news issue, maybe others has the same issue too

email format validation

using macromedia flash with the club starter kit

server error in '/clubwebsite1' application.

why are you profiteering?

user registration

error on default masster page

using this on a server with tight security?

member_list too long, runs over footer toolbar

understanding the memberinfo dataset and adapter

aspnetdb.mdf combined into club.mdf

'http://schemas.microsoft.com/.netconfiguration/v2.0:configuration'

redirect from login

login for admin, after setup

how to change roles for users and make users

problem deploying to sql server 2000 setup

how does the club site starter kit sort the member list?

edit the calendar?

navigation menu

poll_list and poll_view

logged in status not cleared when you log out

help me bout poll integrated

connecting to sql database

call html from another file

is there any way to "highlight" the current page?

clubsite compared with personal starter kit

club site wont work in iis

problem installing club starter kit

club starter kit 2.0 released

loginview - loginview1 error

modififying events so that everything sits in the code behind

changing poster.jpg

userid to other table

application error

e-mail problem

production server setup

can anybody get this to work with netscape or other non internet explorer browsers?

club site starter kit installed ok, but failure using the web site administration tool

v3beta1 clubstarterkit merged with classifieds - up/running in medium trust

need help implementing fckeditor in news_edit.aspx

(new here) help loading the extended club starter kit

using the starter kit w/out access to .mdf files

deletion of agenda

   
  Privacy | Contact Us
All Times Are GMT