Wednesday, June 17, 2015

Show web in Top Link Bar Programmatically using C#

private void DisplayWebAtTopLink(SPWeb webnew)
{
try
{
webnew.Navigation.UseShared = true;
SPNavigationNodeCollection topnav = webnew.ParentWeb.Navigation.TopNavigationBar;
SPNavigationNode node = topnav.Cast<SPNavigationNode>().FirstOrDefault(n => n.Url.Equals(webnew.ServerRelativeUrl));
if (node == null)
{
string linkTitle = webnew.Title;
if (linkTitle.Length > 15)
linkTitle = linkTitle.Substring(0, 12) + “…”;
node = new SPNavigationNode(linkTitle, webnew.ServerRelativeUrl);
node = topnav.AddAsLast(node);
}
}
catch (Exception ex)
{
}
}

No comments:

Post a Comment