 |
|
 |
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string sURL = Request.Url.ToString().ToLower();
if (sURL.EndsWith("default.aspx"))
{
mnuChild.Visible = false;
}
else if (sURL.Contains("/products/") || sURL.Contains("/services/"))
{
smdsChild.StartingNodeOffset = -1;
}
}
} this is giving error that ,, post'System.Web.UI.WebControls.SiteMapPath' does not contain a definition for 'StartingNodeOffset'
|
|
|
|
 |
|
 |
Hey these is really nice piece of work but why are the side pages in visual basic???? WHYYYY... dam i hate visual basic...
|
|
|
|
 |
|
 |
Hello,
This is great... but how can I catch the "OnClicked" event ?
|
|
|
|
 |
|
 |
Please send the answer to san.swamy@yahoo.co.in or gmail.com
Dont mine
thanks
santosh
|
|
|
|
 |
|
 |
Hello Natraj,
I've been searching for this kind of menu since a week. It's really great....
But I've a small problem, could you please tell me HOW can I highlight PARENT node (ex. PRODUCTs) after selecting the child node...
It would be very helpful and saves a lot of time with a small hint from you...
Thanks
Santosh
|
|
|
|
 |
|
 |
Very nice job on this one! Took me a while to understand, but when I got it working, WOW!
However I had trouble with you C code getting it to work. For those of you coding with VB here is my trick.
Put this code in your master page:
Partial Class MasterPage
Inherits System.Web.UI.MasterPage
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim sURL As String = Request.Url.ToString().ToLower()
'Input starting pages with no child menu's. Note: tolower above converts to lower case so dont use any upper case in "xxx.aspx"
If sURL.EndsWith("mainpage.aspx") OrElse sURL.EndsWith("logout.aspx") OrElse sURL.EndsWith("projectlist.aspx") Then
MenuChild.Visible = False
Else
'Input Starting pages with Child Menus. Since you cant duplicate urls in web.sitemap I set up a main page with a redirect to the first page.
If sURL.EndsWith("vendorform.aspx") OrElse sURL.EndsWith("loginmain.aspx") Then
MenuChild.Visible = True
Else
'This handles all child pages. when you click on a child page that is not the starting page from the master, this will keep the Child desplay menu
smdsChild.StartingNodeOffset = -1
MenuChild.Visible = True
End If
End If
End If
End Sub
End Class
Tada, it works for me.
Hope that helps someone. To the author of this post, Thank you very much!
|
|
|
|
 |
|
 |
Very good article, thanks Natarajan
|
|
|
|
 |
|
 |
Hey
Thanks for the article. This is exactly what I was looking to get a start with. Being someone who has been newly hit by css bug I was trying to make a css menu, that will mimic, what you were doing in your example and then I realized that developing in .net is more to make use of existing controls and get them to work rather than build something from scratch. With css adapter for menu we can just about change any style.
Thanks again
Cheers
Shree Menon
menon
|
|
|
|
 |
|
 |
Hy,
This is the article what i needed. It's simple and clear, but you have to correct this article, cuz' "DataSource" property cannot be set declaratively. But with the "DataSourceID", it can be possible to set DataSource for the Menu Control.
|
|
|
|
 |
|
 |
I love the Parent/Child menu system and want to use it on my site, but I've looked at several examples including this one and am still struggling to get it to work completely the way I am hoping. This one is the closest...
I have the parent menu, child menu and a contentplaceholder on my master page. I want the parent and child menus both visible all the time and the content in synch.
The example on this website works wonderful for this purpose, BUT... the child menu keeps disappearing and I can't seem to find the parameter to change this. I've tried so many variations I'm completely confused... I've copied everything from this site and used it for the example, and the child still disappears.
Can anyone please tell me how to keep the child menu from disappearing?
Thank you for this wonderful example, it's taught me a great deal. I'm new to asp.net.
fiddlewidget@yahoo.com
|
|
|
|
 |
|
 |
Hi, Nataraj. Thank you for your article. It is very helpful for me.
So, I have one question. When I select in a child (vertical) menu one of the node, for example Servcie1 (see last picture), after page reloading there isn’t displayed information in what node of Main menu I’m currently stay. I mean that in main horizontal menu is not selected appropriate node (for my example - Services) according to selected child node.
Could anyone help me please?
Thanks in advance,
Elena
|
|
|
|
 |
|
 |
Thanks to Nataraj for a nice article that got me started on sitemaps and a way to do menus in masterpages without the hurt of url string hacks. I have the same problem that the top menu does not stay selected after selecting horizontal menu item. Solution is very appreciated. Or if you have other ways to solve the "multi level menu in master page" problem please guide me
|
|
|
|
 |
|
 |
I'm an ASP beginner, so my question maybe stupid.
After clicking on a childmenu-entry, the childmenu disappear!?
Is it possible that after clicking on the childmenu the menu is still visible?
Hope someone can help.
|
|
|
|
 |
|
 |
You're right... The question is stupid :P
What do you mean the childmenu disappears?
Where were you when you clicked on the menu? Running the page or still on the IDE?
You mean you want to keep the menu open and visible after it has been clicked?
You know, when you click on a destination(link), you arrive at a completely different page and that may be why the menu is invisible.
E.G. I was reading my email when I came across the CodeProject newsletter. I clicked on a link that brought me to this project page, but...
Oh No! I can't see my email anymore until I go back!
|
|
|
|
 |
|
 |
Ghostnet,
Just a word of wisdom: When you give advice, please try to understand the problem first...
Baloreska, no question is a stupid one. One learns by asking questions, and thats clever.
I found the following:
The childmenus do indeed disappear. But it is just the way the JavaScripts are generated by the controls (most fly-out menus do not keep displaying their children after a click, but obviously one can code it to do so).
Although I have never used this menu control myself before, it seems to me that the menus use the sitemap nodes in the XML file as "identifiers". The example has "#1", "#2", etc, as url links for child products and services. I replaced them with more realistic urls, like "products.aspx?id=1", etc, them the complete menu disappear. If you link to "products.aspx" then the menu displays.
There is no code in the code behind file, so it must be default behaviour in the control.
I guess the example was intended only as a brief intro about the concept, but surely a real world example would clarify things for me too.
Sorry, I know this does not help you much, but maybe someone else has used this control before.
Old dogs can learn new tricks. I am proof of that... been programming for 22 years and still learn every day!
|
|
|
|
 |
|
 |
Andre K wrote: Just a word of wisdom: When you give advice, please try to understand the problem first...
Eh?
"After clicking on a childmenu-entry, the childmenu disappear!?"...Doesn't help much.
I was trying to "understand the problem" when I asked all those questions trying to figure out what the problem was exactly and where he was seeing it.
I see "The menu disappears" type questions all over my news server, and a lot of those are simply common sense. As you said, simply altering the menu to keep open. I didn't even think about it when I saw it, since it did exactly what I expected. This wasn't a "problem".
Andre K wrote: Old dogs can learn new tricks. I am proof of that... been programming for 22 years and still learn every day!
Good for you! You've been a programmer a year less than I've been alive
I'm not really a programmer.
But I learn everyday how avoid problems that don't exist.
|
|
|
|
 |
|
 |
Here I agree with you, the menu behaves exactly the way it was coded. The problem this other dude has, is that he expects to see the last level of the child menu stay open on the left when he select a link. Obviously he wants to stay inside a page that uses the masterpage, and not navigate away from his site. Like you said, a new window could not possibly show his child menu! he he he
Even I would like to know why the menu doesn't just expand and display the next level. What is the purpose of using an existing control, if one would have to spend more time trying to figure out how to do simple things, than writing your own?
-- modified at 3:27 Wednesday 16th August, 2006
|
|
|
|
 |
|
 |
Ah yes that's exactly what I meant.
I usually hit DynamicDrive[^] or similar place for my menues while doing minimal changes server-side. I think having to link back to DD is a small price for not having to write another menu from scratch each time.
Or if it's really simple, I leave JavaScript out of the whole thing and just use a list. (ul, or ol).
More accessible anyway.
I'm not sure how you took my other post, but reading it again... Wow that was rude!
I really didn't mean to sound like an a**.
It's early morning for me right now, and I still have a few hours of work left.
And we ran out of coffee!!
I apologize, I meant no disrespect. It's just that I really thought I was being straightforward.
|
|
|
|
 |
|
 |
hi,
The solution seemed great.
But i have a problem.
The child menu is visible when I run the application.
And also, I have more than 6 menu items and for each menu item in the horizontal menu, I need the submenus in the vertical menu.
So, the else if condition in the masterpage on load method would be lengthy.
Any Alternate to it??
Your immediate response is highly appreciated.
thanks,
sreelu
|
|
|
|
 |
|
 |
Sorry, I mean't vertical menu is not visible when i run the application.
Any suggestions.??
|
|
|
|
 |
|
 |
Can you pls confirm whether you meant to have some thing like below?
We have [Home] - [Products] - [Services] menu bar in top of all pages
Clicking on Products in top menu displays a common page Product.aspx where in the left menu lists the links to all the products pages (eg:- Product1, Product2 and Product3)
Clicking on Product1 takes to the Product1.aspx where the left menu displays nothing.
Similarly clicking on Product2/Product3 takes to the corresponding product page where the left menu displays nothing.
But what you want is to maintain that left menu visible for all these products pages.
If that is the case you may need to add few lines of code in the masterpage's page load event. As oon as possible I will update this article with that secenario too.
-- modified at 22:02 Wednesday 16th August, 2006
I have updated the article with new code. Please check and let me know if you all meant the same functionality.
----------------------------------------------------------------------
All most anything you do will be insignificant but it is very important that you do it.
|
|
|
|
 |
|
 |
Ah yes that's exactly what I meant.
Thanks for your solution.
|
|
|
|
 |
|
 |
I also spent a while to figure out the logics in MasterPage.master.cs.
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string sURL = Request.Url.ToString().ToLower();
if (sURL.EndsWith("default.aspx"))
{
mnuChild.Visible = false;
}
else if (sURL.Contains("/products/") || sURL.Contains("/services/"))
{
smdsChild.StartingNodeOffset = -1;
mnuChild.Visible = true;
}
}
}
else if (sURL.Contains("/products/") || sURL.Contains("/services/"))
This statment means that the left menu is visible only if the clicked child page is in the products or services folder.
|
|
|
|
 |