3

I am using SharePoint Server 2007 Enterprise with Windows Server 2008 Enterprise, and I am using publishing portal template. I am developing using VSTS 2008 + C# + .Net 3.5. I am using left navigation area (in SharePoint terms, it is also called current navigation area), and each item in the left navigation area maps to either a sub-site or a specific URL (i.e. clicks the item in left navigation area will display content of welcome page of the specific sub-site or the content of the specific URL in the main content area on the central area).

I want to know which URL is displayed on the main content area when an item in the left navigation area is clicked. Any samples to make a reference?

thanks in advance!

3 Answers 3

5

Could you tell a bit more on what part of the object model you are using?

If you are coding navigation api, theres other better approaches with the whole sitemap provider framework (like PortalSiteMapProvider).

If you just want the current information in general, you can always use SPContext.Current to get hold of data like current web, site, list, listitem etc.

For example current user: SPContext.Current.Web.CurrentUser will return an SPUser object for current user.

To get current URL using SPContext.Current use

  • SPContext.Current.Web.Url for absolute url
  • SPContext.Current.ServerRelativeUrl for the relative position of web on site
2
  • What do you mean "what part of the object model"? Could you describe in more detail please?
    – George2
    Commented Dec 7, 2009 at 15:14
  • Actually, I just create some child sites and by default in left navigation area of parent site, it contains link to each child site. When such link is clicked, I want to know which link is clicked. Any solutions?
    – George2
    Commented Dec 7, 2009 at 15:15
1

Try this :

SPContext.Current.ListItemServerRelativeUrl
0

Try this

string SiteUrl = SPContext.Current.Site.Url;//Get the url of current site
SPSite site = new SPSite(SiteUrl);//open the site with the url passed
SPWeb oWeb = site.OpenWeb();//open the web

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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