Question

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!

Was it helpful?

Solution

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

OTHER TIPS

Try this :

SPContext.Current.ListItemServerRelativeUrl

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
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top