1

Is it possible to pull the value of a property, from a web part into XSL?

I need to build something similar to the standard Summary Link Web Part, but would like to extend the default control with only a single property which will allow the editors of the site to supply a URL to a link, located in the footer-item of the SummaryLinkMainQuery.xsl.

8

Definitely passing webpart values to XSLT is possible for all classes which inherit from DataFormWebPart, and can be easily done through ParameterBinding:

<ParameterBinding Name="WPPropertyBinding" Location="WPProperty(Title)" />

Use your custom property name instead of Title.

If you're using a standard SummaryLinkWebPart and you need only to fix XSL transformation, then all you have to do to achieve this, is to add the parameter binding string shown above to ParameterBindings property of SummaryLinkWebPart.

Then, in XSLT, reference this parameter using following xsl code:

<xsl:param name="WPPropertyBinding" />

From this point, you will be able to use the parameter in XPath queries, for example:

<xsl:value-of select="$WPPropertyBinding" />

Read more about ParameterBindings on Stefan Stanev's blog, he has a really comprehensive article about it:

3

Watch out as SummaryLinkWebPart is a sealed class - you can't inherit it. Basically you'd have to build it from scratch.

2
  • just saw that as well. i wanted to get assurance that there is a way to call property values in xls, let's say "MyProperty {get; set;}", how would I call that in XSL? "<%=this.MyProperty%>" or something similar? – JadedEric Oct 26 '11 at 7:29
  • You could /try/ and adding to the list of xsl params that are at the top of the Main xsl. – James Love Oct 26 '11 at 8:18

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.