I have done some searching, but did not find exactly what I am looking for. I have an existing XSLT macro, which has been able to successfully render the output I need up to this point. The problem I have now is that I also have a .NET usercontrol in C#, which takes a couple of Umbraco page fields and outputs a specific hash string.
I need to insert the string output from the .NET usercontrol into a specific point in my XSLT output (inserting hashed source value into a Silverlight control). I have a couple ideas around this, but they all seem fairly complicated and I am wondering if there may be simple way to meet my needs.
Are you sure what you're trying to do can't be achieved building an extension, which can be used in the XSLT instead? Including a User control in a XSLT file does not make sene I think.
But if you create your own XSLT extension you can pass the values to the XSLT as needed.
If you just need to serve some umbraco properties to your user control I think you should be able to do that setting some properties and then feed them to the macro once it get's inserted. But you can't mix a user control into XSLT.
Thanks Jan for the response. Since I already have both the XSLT and .NET usercontrol macros working perfectly, I was hoping to keep them intact, but it looks like that's just not going to happen.
I was under the impression that scripting within XSLT was bad practice, but perhaps I should read more about that.
I'll also look more into creating an XSLT extension, as it sounds like that might be my best bet.
Like Jan suggestions, an XSLT extension sounds ideal for your requirement.
You're right about inline scripting in XSLT being bad practice - try to avoid that at all costs. If you do need to write something quick, then put the code/script in your App_Code.
As for trying to render a .NET-based macro from within XSLT, it doesn't work. I believe it is to do with the stage that the XSLT is rendered in relation to the ASP.NET page life-cycle - but don't quote me on that, not 100% sure! All I know is that I've tried it too and it doesn't work! ;-(
Wow. That was so easy! I just built my 1st XSLT extension and my only question is why didn't I ever do this before? It does EXACTLY what I needed. All I keep thinking about now is how many things over the past year I could have done with this.
For anybody else interested there is a great video on umbraco.tv to get you started, then you just need to plug in your C# code.
Again, thanks Jan and Lee for pushing me in the right direction.
Good to hear you got a revelation on this subject - it's a nice feeling when you get the bricks to fall into place and have another tool in the belt for future projects.
Render UserControl Macro in XSLT
Hello,
I have done some searching, but did not find exactly what I am looking for. I have an existing XSLT macro, which has been able to successfully render the output I need up to this point. The problem I have now is that I also have a .NET usercontrol in C#, which takes a couple of Umbraco page fields and outputs a specific hash string.
I need to insert the string output from the .NET usercontrol into a specific point in my XSLT output (inserting hashed source value into a Silverlight control). I have a couple ideas around this, but they all seem fairly complicated and I am wondering if there may be simple way to meet my needs.
Any suggestions?
Thanks in advance,
jt
Hi Jeff
Are you sure what you're trying to do can't be achieved building an extension, which can be used in the XSLT instead? Including a User control in a XSLT file does not make sene I think.
But if you create your own XSLT extension you can pass the values to the XSLT as needed.
You could also write some inline C# code in the XSLT file if that helps you. You can see an example on how to do that here: http://forum.umbraco.org/yaf_postst2996_Accessing-QueryString-Within-C-Within-XSLT.aspx (nevermind the code - just an example of how you need to markup the section with C# code in the XSLT file).
If you just need to serve some umbraco properties to your user control I think you should be able to do that setting some properties and then feed them to the macro once it get's inserted. But you can't mix a user control into XSLT.
/Jan
Thanks Jan for the response. Since I already have both the XSLT and .NET usercontrol macros working perfectly, I was hoping to keep them intact, but it looks like that's just not going to happen.
I was under the impression that scripting within XSLT was bad practice, but perhaps I should read more about that.
I'll also look more into creating an XSLT extension, as it sounds like that might be my best bet.
Thanks
Hi Jeff,
Like Jan suggestions, an XSLT extension sounds ideal for your requirement.
You're right about inline scripting in XSLT being bad practice - try to avoid that at all costs. If you do need to write something quick, then put the code/script in your App_Code.
As for trying to render a .NET-based macro from within XSLT, it doesn't work. I believe it is to do with the stage that the XSLT is rendered in relation to the ASP.NET page life-cycle - but don't quote me on that, not 100% sure! All I know is that I've tried it too and it doesn't work! ;-(
Cheers, Lee.
Thanks for the help guys. Much appreciated.
Wow. That was so easy! I just built my 1st XSLT extension and my only question is why didn't I ever do this before? It does EXACTLY what I needed. All I keep thinking about now is how many things over the past year I could have done with this.
For anybody else interested there is a great video on umbraco.tv to get you started, then you just need to plug in your C# code.
Again, thanks Jan and Lee for pushing me in the right direction.
Hi Jeff
Good to hear you got a revelation on this subject - it's a nice feeling when you get the bricks to fall into place and have another tool in the belt for future projects.
umbraco.tv is worth the money for sure :-)
/Jan
is working on a reply...