Passing "&" through query string for DVWP query filter value

Posted on 2012-09-06
Last Modified: 2012-09-07

I'm trying to configure a sharepoint 2007 dataview webpart to filter the list based on parameters passed through the URL.

This is all working, although I have come across a value in the list which has an "&" symbol in the text.

How do I pass this value through the URl so that sharepoint interprets it as part of the text rather than a seperator for the next variable?

I've seen other posts with this problem, and they used encode URL as the solution, although I'm not sure I can use that here as its a dataview webpart picking up the variable so I can't see how I'd get it to decode the URL.

Question by:bedsingar
    LVL 9

    Expert Comment

    by:Derek Jensen
    encodeURI should work regardless, as & is an ASCII encoding standard. If sharepoint doesn't know how to interpret this, then it's not a very good program. But, I'm fairly certain it does. :-)
    LVL 82

    Accepted Solution

    If you are coding an HREF url, assuming you want to pass "company=AT&T" as well as "category=telephone", then you should code as follows:

    <a href="page.aspx?company=AT%26T&category=telephone">...</a>

    The %26 represents the "&" in "AT&T" and is interpreted as actual text.  In case you are wondering where the %26 came from, refer to:

    Under the "Chr" column look for the "&" symbol.  Then locate its numeric value under the "Hx" column and prefix that numeric value with a percent symbol.  The same rationale applies for other special url symbols (/, =, ?, etc).

    Author Closing Comment

    %26 worked perfectly without need for any modification to the sharepoint list / data view.

    For info I also tried the &amp ... this didn't work on the sharepoint list.

    Thanks for your help.

    Featured Post

    Courses: Start Training Online With Pros, Today

    Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

    Join & Write a Comment

    Pimping Sharepoint 2007 without Server-Side Code Part 1 One of my biggest frustrations with Sharepoint 2007 in the corporate world is that while good-intentioned managers lock down the more interesting capabilities of Sharepoint programming in…
    Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now