Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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!

share|improve this question
add comment

3 Answers

up vote 5 down vote accepted

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
share|improve this answer
    
What do you mean "what part of the object model"? Could you describe in more detail please? –  George2 Dec 7 '09 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 Dec 7 '09 at 15:15
    
Thanks, question answered! –  George2 Dec 9 '09 at 9:58
add comment

Try this :

SPContext.Current.ListItemServerRelativeUrl
share|improve this answer
add comment

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
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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