1

Has any ever tried calling an embedded C# function from within content query XSL?

Contrived example:

The exception in the SharePoint log is:

System.Xml.Xsl.XslTransformException: Execution of scripts was prohibited. Use the XsltSettings.EnableScript property to enable it.

Given that I only have "control" of the XSL and not the underlying code for the web part, am I simply out of luck or is there some way?

1 Answer 1

1

I'm sure some have tried but failed miserably as embedding the code directly in the XSL is highly unwanted. Not even javascript is recommended embedding unless it is functionreferences only.

Changes made in the XSL will require you to add something to the templates. Templates are applied to items present in the CQWP. So if you have 5 items, the code will be added 5 times to the page as it gets applied to every single item.

If you have some custom C# code that needs to be executed at whatever point in the CQWP lifecycle, it is recommended that you create a custom web part inheriting the ContentByQueryWebPart class.

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.