6

I have used structural navigation in my site.In site settings->Navigation,while specifying the url,I am not able to pass query string along with url. Example: http://sitecollection/page.aspx is accepted whereas http://sitecollection/page.aspx?k=hr is not working.While passing the query string along with url,query string is getting ignored.Can anyone suggest the root cause of this problem? Is this a sharepoint behaviour in terms of navigation?

1 Answer 1

3

Write code as below:

string url = " http://sitecollection/page.aspx>k=hr";
string title = "HR";

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

or another method is:

var newNode = new SPNavigationNode("HR", "http://sitecollection/page.aspx");
newNode = web.Navigation.QuickLaunch.AddAsFirst(newNode);
newNode.Properties.Add("NodeType", "AuthoredLinkPlain");
newNode.Properties.Add("UrlQueryString", "k=hr");
newNode.Update();

You need to set the IsExternal property to true. After that it will start accepting query string or the second method which will add query string property to property bag.

Your Answer

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

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