The buzz with "UrlQueryString" in SharePoint navigation

SharePoint’s navigation APIs have a property exposed that allows us to set query string properties for a URL.  Sadly, but not surprisingly, this only works when root site collection has publishing feature enabled.  Reason is simple…

One a WSS only OR on a site where publishing feature is not enabled, the property “UrlQueryString” is not available in the default property enumeration of the navigation node’s property collection.  Run a simple code like the following

   1:                     SPNavigationNodeCollection quickLaunchNodes = web.Navigation.QuickLaunch;
   2:                     foreach (SPNavigationNode parentNode in quickLaunchNodes)
   3:                     {
   4:                         if (parentNode.Title.Equals(“Lists”))
   5:                         {
   6:                             foreach (SPNavigationNode childNode in parentNode.Children)
   7:                             {
   8:                                 Hashtable ht = childNode.Properties;
   9:                                 foreach (string key in ht.Keys)
  10:                                 {
  11:                                     MessageBox.Show(key);
  12:                                 }                                
  13:                             }
  15:                         }
  16:                     }

And you’ll see the property collection returned on a WSS only OR a site where publishing feature is not enabled returns only one property “vti_navsequencechild” and it’s value will be set to “True”.  Whereas when you enumerate this property bag on a publishing feature enabled site collection, you’ll see at least 8 properties as show below

    Count = 8
[“vti_navsequencechild”]: “true”
[“CreatedDate”]: {7/24/2008 11:16:59 AM}
[“UrlQueryString”]: “”
[“LastModifiedDate”]: {7/24/2008 11:58:52 AM}
[“Audience”]: “”
[“Target”]: “”
[“Description”]: “”
[“UrlFragment”]: “”

“UrlQueryString” is available as one of the properties to be set and so will take effect when set with a query string parameter value.  On a site where publishing feature is not enabled, you’ll still be able to set this property with a value, but there will be no effect in the UI.  Yep! it doesn’t sound good, but that’s the way it is 🙁

Check this article out!