views:

519

answers:

2

Is there any way to render ASP.net MVC controls or code directly within a XSLT/XSL transform file under the .NET Framework? If so can you provide me with a sample or link?

+1  A: 

Although this is possible (use the same strategy as you would with html, but harass VS frequently to make it work, and use raw text outputs for anything that XSLT is too stubborn to touch), this is almost definitely not what you actually want to do. Even if you already have XSLT for generating html documents, this strikes me as a bad idea. Instead, you should try searching for "Asp.Net Data Binding XML." You'll find results like this, which will probably give you considerably better and more maintainable results.

Brian
Yeah, I would avoid it too in a real project anyway... I am just interested in seeing in how this is implemented. Currently I am just passing in param's via asp.net and it works fine. thanks though
Andrew
+2  A: 

I'm reading a great ASP.NET MVC book by Apress: http://www.amazon.com/Pro-ASP-NET-Framework-Steven-Sanderson/dp/1430210079

In Chapter 10, there is a section called "Implementing a Custom View Engine", which shows you step by step how to implement an XSLT view engine. Its actually pretty simple (wish I could post it, but don't want to violate copyright).

I highly recommend this book to anyone (I bought and downloaded the e-book on their web site), the author really explains things well. ... OTOH, I recommend you avoid those red books with the authors' mug shots on them... unless you like books that consist mainly of screen shots and code dumps, with little effort on explaining concepts clearly.

DSO
Thank you sir, my co-worker has this book and I shall give this chapter a read :).
Andrew