Showing posts with label Navigation. Show all posts
Showing posts with label Navigation. Show all posts

Monday, June 11, 2012

Add SPNavigation Heading programmatically

If you want to add header without link to SharePoint Navigation pro-grammatically,  Need to set some values in the NavigationNode.Properties HashTable.


            SPNavigationNode node, node1;
            // Get the parent’s top link bar.
            SPNavigationNodeCollection topnav = web.Navigation.TopNavigationBar;

            // Create the node.
            node = new SPNavigationNode("News", "/news", true);
            topnav.AddAsLast(node);

            node = new SPNavigationNode("Services", string.Empty, true);
            node = topnav.AddAsLast(node);
            node.MakeHeaderNode();
            node1 = new SPNavigationNode("IT Support", "/Services/Lists/Helpdesk Initiation/NewForm.aspx?RootFolder=&source=/", true);
            node.Children.AddAsLast(node1);


public static class SPNavigationNodeExtensions
{
    public static void MakeHeaderNode(this SPNavigationNode node)
    {
        node.Properties["BlankUrl"] = "True";
        node.Properties["LastModifiedDate"] = DateTime.Now;
        node.Properties["Target"] = "";
        node.Properties["vti_navsequencechild"] = "true";
        node.Properties["UrlQueryString"] = "";
        node.Properties["CreatedDate"] = DateTime.Now;
        node.Properties["Description"] = "";
        node.Properties["UrlFragment"] = "";
        node.Properties["NodeType"] = "Heading";
        node.Properties["Audience"] = "";
        node.Update();
    }
}
As you can see, the “BlankUrl'” = True, and NodeType = “Heading”.

Thursday, November 10, 2011

SharePoint Publising Page Problem MOSS Page Setting Error - Value does not fall within the expected range

When try to access publishing page or page setting getting error “Value does not fall within the expected range” . This error only happens when you copy an aspx page using SharePoint designer from one server to another severs (development server to production server). Also if you copy pages in the same server and changed alternate access mapping url.

Solutions:

  1. You cannot copy and paste the aspx page using SharePoint designer. First, export the aspx page using SharePoint designer to a physical file.
  2. Open the aspx page with notepad and search on the “mso:PublishingPageLayout”. You will notice your development portal URL is there.
    <mso:PublishingPageLayout msdt:dt=”string”>http://xxxdevelopmenturl/_catalogs/masterpage/BlankWebPartPage.aspx, Blank Web Part Page</mso:PublishingPageLayout>
  3. Replace your development URL (xxxdevelopmenturl) to the production URL or remove http://xxxdevelopmentur and save it.
  4. Open your production site with SharePoint Designer and import the modified aspx page.

If you found this error in production server open site using SharePoint Designer go to TaskPane-->Hyperlinks and edit hyperlinks of layouts like above sample:
Replace:http://xxxdevelopmenturl/_catalogs/masterpage/BlankWebPartPage.aspx
By: /_catalogs/masterpage/BlankWebPartPage.aspx

Also you can fix programmatically check url:

http://support.microsoft.com/kb/953445

Also Check this if you found your any modifications Navigation setting aren't saved.
or an error like image below:

Sunday, January 23, 2011

Unable to modify navigation - Add heading/link

When I Try to modify Navigation in a site and add a heading, this is not working. When pushing OK, there is nor error messages appearing, but the heading is not showing up.
Problem missed navbar nodes of the onet.xml in custom site template.
  • Solution add NavBar nodes to onet.xml:<navbars>
    <navbar name="SharePoint Top Navbar" id="1002">
    </navbar>
    </navbars>
  • Wrote an SQL query to update the broken sites. T-Sql to execute in contentdbINSERT INTO [NavNodes] ([SiteId] ,[WebId] ,[Eid] ,[EidParent] ,[NumChildren] ,[RankChild] ,[ElementType] ,[Url] ,[DocId] ,[Name] ,[DateLastModified] ,[NodeMetainfo] , NonNavPage] ,[NavSequence] ,[ChildOfSequence])
    SELECT DISTINCT SiteId, WebId ,1002 ,0 ,0 ,1 ,1 ,'' ,NULL ,'SharePoint Top Navbar' ,getdate() ,NULL ,0 ,1 ,0
    FROM NavNodes
    WHERE WebId NOT IN (
    SELECT WebId
    FROM NavNodes
    WHERE Eid = 1002)
  • The query adds the SharePoint Top Navbar node to the NavNodes tables where a web does not already have one.