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?

4

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

| improve this answer | |
  • 3
    Or change constructor to: new SPNavigationNode(title, url, true); Thanks! – Tschareck Mar 20 '13 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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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