I have two sitecollection A and B, i want to write a c# code on my webpart to read the topnavbar of sitecollection A at sitecollection B and display the same in ASPMenu control on site collection B.

So in nut shell my requirment is to display same menu accorss site collection in a webapplicaton and this should be dyanamically so when any new subsite added to any site collection all site collection will have the link at the same.



I wrote a post in my blog about this issue. Please, look here.

But in your case you should use

source.SiteMapProvider = "GlobalNavigation"; 

Also you should look at your web.cofig to set correct params of site map provider.

| improve this answer | |
  • Thanks for your response, Just wanted to let you know my requirment in detail. I am having three sitecollection name A/B/C, all site collection having two subsite e.g. A1/A2 B1/B2 C1/C2 and finaly i want to display a menu like there will be there link A/B/C and when you do the click/mouse over on any item A/B/C sub menu will open for respective site collection. e.g. you have click on A sub menu will have two option A1 and A2 same for other B and C. Also when you go on any site collection or subsite all will have same pattern. – Yogi Mar 26 '12 at 20:08
  • Continue to last comment;;; also when ever any new sub site added to any site collection show display new option in that menu. The approch i am using to raed all topnav bar and combine but doing some mistake. – Yogi Mar 26 '12 at 20:08
  • this approach describes how to display menu from other site collection, thus you will have full copy of menu from site wich you would like to show. if you change menu items in source site, the changes are applyed in your target site. If your would like to show several menus, I suggest to add several controls for top menu rendering and use several data sources. You can place these controls one by one. – Alexander Mar 26 '12 at 20:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.