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 some links to Quicklaunch bar. The link needs to have query string parameters, eg.: /sites/project/default.aspx?mode=filter

string url = "/sites/project/default.aspx?mode=filter";
string title = "Filter";

SPNavigationNodeCollection quickLaunch = web.Navigation.QuickLaunch;
SPNavigationNode newnode = new SPNavigationNode(title, url, false);
web.Navigation.QuickLaunch.AddAsLast(newnode);

Unfortunatelly, this code adds quicklaunch link without the parameter, ie.: /sites/project/default.aspx.

What is correct way to add link with params from code?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

In the SPNavigationNode make the isExternal variable as true . Check this article Link

share|improve this answer
2  
Or change constructor to: new SPNavigationNode(title, url, true); Thanks! –  Tschareck Mar 20 '13 at 8:32

I know this is quite old post, but setting IsExternal to true works.. but isn't the correct way of adding Query String..

Here is how you add a Query String:

string url = "/sites/project/default.aspx";
string title = "Filter";

SPNavigationNodeCollection quickLaunch = web.Navigation.QuickLaunch;
var newNode = new SPNavigationNode(title, url, false);
quickLaunch.AddAsLast(newNode);
newNode.Properties["UrlQueryString"] = "mode=filter";
newNode.Update();

Reference:

programmatically passing navigation node url with querystring

share|improve this answer

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.