Extract current URL for use in conditional formatting of DVWP values

Posted on 2011-10-17
Last Modified: 2012-05-12

I have a DVWP which lists the web part pages of a library. The metadata for these pages allows for a four-tier hierarchy, and I've built the DVWP to show the respective groupings etc.

This part works fine. I can collapse and expand groups and drill down to the level I need, then click the entry I want and the desired page is displayed.

All these web part pages have the same DVWP as a navigation panel.

I would like to use conditional formatting to highlight the current page link in the DVWP. For example:

I have three pages, green.aspx, red.aspx, blue.aspx. They all have a DVWP listing the three pages


When I open blue.aspx, I'd like conditional formatting to highlight the entry "blue.aspx" in the DVWP.

I can set up conditional formatting for all kinds of comparisons among the DVWP values. But how can I determine the URL of the current page, so I can compare it to the respective field of the DVWP?  

I'm using SP 2010 Enterprise and SPD 2010. I am not interested in a solution that involves Visual Studio, C# or any tools outside of the SP 2010 GUI or SPD.

The ultimate goal is to create a multi-tiered navigation pane that goes down to a document level and includes only a specific library. If anyone has a better approach, I'm all ears.

cheers, teylyn
Question by:teylyn
    1 Comment
    LVL 50

    Accepted Solution

    Found the solution myself:

    I created a parameter for the DVWP and used a server variable that holds the URL.

    Here are the steps:

    To create a parameter for conditional formatting of the link that is the same as the current page:
    - click in the DVWP in Design window
    - on the Options ribbon, click "Parameters" > New Parameter
    - name the new parameter, for example "srvVar_URL"
    - in "Parameter Source" select "Server Variable"
    - in Server Variable Name enter "URL" (without the quotes)

    To create the conditional formatting
    - click in the DVWP in Design window
    - Options Ribbon > Conditional Formatting > Format Row
    - from the Field Name dropdown, select "URL Path"
    - from the Value dropdown, select "[srvVar_URL]" (or the parameter name defined above)
    - click "Set Style" and define the style.

    cheers, teylyn

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    For SharePoint sites, particularly public-facing ones, there are times when adding JavaScript, Meta Tags, CSS Styles or other content to the page <head> section is more practical than modifying master pages.  For instance, you could add the jQuery l…
    Microsoft SharePoint Foundation 2010 and Microsoft SharePoint Server 2010 do not offer the option to configure the location of the SharePoint diagnostic trace log files during installation.  This can, however, be configured through Central Administr…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    779 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

    12 Experts available now in Live!

    Get 1:1 Help Now