views:

34

answers:

2

I would like to use the asp.net mvc actionlink and form controls in xslt code. How do I go about doing this? is this notpossible to do in xslt? I could not find a solution online.

+1  A: 

It's possible. Check out these links to get you started.

http://blog.stevensanderson.com/category/xslt/

http://weblogs.asp.net/jigardesai/archive/2008/02/08/xslt-transformation-in-asp-net-mvc-framework.aspx

http://derek-says.blogspot.com/2008/05/creating-views-using-xsl-in-aspnet-mvc.html

Last but not least.... A sample on codeplex doing this. http://tpeczek.codeplex.com/releases/view/45199

EDIT: Upon further thought...

Since it seems you are wanting to use XSLT at runtime then rendering an action link or other controls using the helpers in MVC won't work. The XSLT will spit out the action link or control based on your entered transformation but the MVC engine will not execute on it to create the resultant html.

If you were doing this at design time say as part of a code generator then you could use the XSLT to create your views but you would still have to take the resultant file and use that as your view in your application.

klabranche
Hmmm..i checked all links but it does not show an example of how to render MVC controls in xslt.
Luke101
Hmmm.... I thought the first link did... sorry about that. :-(
klabranche
A: 

Not possible. The ASP.NET MVC HTML helpers produce strings, while XSLT produce a tree of nodes.

Max Toro