SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For an event receiver, I want to execute some custom code when a list is added to my site. I want to use the OnQuickLaunch property of the list, but that doesn't seem to correspond to the "show on quicklaunch" checkbox when adding a new list?

When I add a new list and set the checkbox to true; the property still reads false in ListAdded. Is it possible to read this checkbox from ListAdded?

share|improve this question
var navNode = new SPNavigationNode( yourList.Title, yourList.DefaultViewUrl);
SPContext.Current.Web.Navigation.AddToQuickLaunch(navNode, SPQuickLaunchHeading.Documents);

Will add your node to Documents section in quicklaunch.

yourList.OnQuickLaunch = true should also work as long as you remember to list.Update() afterwards.

share|improve this answer
I know that, but I don't want to add the list to the navigation since SharePoint can do that perfectly. But I do want to know if the new list is going to be on the Quicklaunch, depending on if the user checked the checkbox or not. SPWeb.OnQuickLaunch always returns false. – Jasper Jan 6 '12 at 7:39

Just did a quick test now with this code:

    private Guid _newlistguid;

    public override void FeatureActivated(SPFeatureReceiverProperties properties)
        var w = properties.Feature.Parent as SPWeb;
        _newlistguid = w.Lists.Add("TestList", "Some description", SPListTemplateType.Tasks);
        var newList = w.Lists[_newlistguid];
        newList.OnQuickLaunch = true;

        //Load list again to check value of OnQuickLaunch Param
        var reloadedList = SPContext.Current.Web.Lists[_newlistguid];
        var onQuickLauch = reloadedList.OnQuickLaunch;

The onQuickLaunch parameter on the last codeline contains true after code has executed, so it should give you the correct value. Again, remember to call .Update() on your list after you set the list.OnQuickLaunch value.

Update 12.01:

I had no problems using ListAdded either:

public override void ListAdded(SPListEventProperties properties)
    var l = properties.List;  
    _newlistguid = l.ID;  
    l.OnQuickLaunch = true;  

    var w = l.ParentWeb;  
    //Load list again to check value of OnQuickLaunch Param  
     var reloadedList = w.Lists[_newlistguid];  
     var onQuickLauch = reloadedList.OnQuickLaunch;  

onQuickLaunch contains correct value (true). If you still can't get it to work, please provide code sample of what you are doing.

share|improve this answer
But this code is based on a feature receiver, I don't have any problems there. Try the same in a listreceiver and use the ListAdded event. I find it impossible to get the correct status there. – Jasper Jan 11 '12 at 11:12

Your Answer


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.