1

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?

2 Answers 2

5

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

1
  • 3
    Or change constructor to: new SPNavigationNode(title, url, true); Thanks!
    – Tschareck
    Mar 20, 2013 at 8:32
1

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

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.