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 want to add an event to one of my quicklaunch items in SharePoint, but I don't know how to do that.

Or maybe to link the item to a page that would do what I want and then close and then come back to the previous one.

Do you have any idea how I can do this ?

share|improve this question

migrated from stackoverflow.com Jun 1 '12 at 15:06

This question came from our site for professional and enthusiast programmers.

    
Via code or UI? –  Ryan Jun 3 '12 at 10:52
    
What exactly will the event do? I mean what kind of functionality do you want to add to the Quick launch menu? –  Vardhaman Deshpande Jun 4 '12 at 2:01

2 Answers 2

Here is a method to add an item to the quick launch in C#

private void AddNodeToQuickLaunch(string linkName, string SiteToOpen, string pathtoPage)
   {
       try
       {
           using (SPWeb web = SPContext.Current.Site.OpenWeb(SiteToOpen))
           {
               web.AllowUnsafeUpdates = true;

               SPNavigationNodeCollection nodes = web.Navigation.QuickLaunch;

               SPNavigationNode createNode = new SPNavigationNode(linkName, pathtoPage, true);

               foreach (SPNavigationNode node in nodes)
               {
                   bool nodeExists = false;
                   if (node.Title.Equals("Lists"))
                   {
                       foreach (SPNavigationNode child in node.Children)
                       {
                           if (child.Title == linkName)
                           {
                               nodeExists = true;
                           }
                       }

                       if (!nodeExists)
                       {
                           node.Children.Add(createNode, node);
                       }
                   }
               }
               web.AllowUnsafeUpdates = false;
           }
       }
       catch (Exception ex)
       {
           throw ex;
       }
   }
share|improve this answer
    
While this may theoretically answer the question, we prefer inclusion of the essential parts of the answer here, and to provide the link for reference. See answer for general guidelines. Also we require disclosure of any affiliation with products or websites. Please see May I promote products or websites I am affiliated with here? for guidelines. –  SPDoctor Jul 20 '13 at 10:00

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.