Passing data from C# to XSLT Options
jbrisko
Posted: Friday, November 14, 2008 8:40:11 PM
Rank: Enthusiast

Joined: 8/19/2008
Posts: 40
Location: Utah, USA
Hey guys, I have a situation where I need to pass generated data from a C# user control, back into an xslt macro as a variable or some other way of acessing it. I'm having the c# user control pass back a set of nodes such as...

Code:

<nodes>
        <node id="4052" />
        <node id="4625" />
        <node id="4651" />
        <node id="4325" />
        <node id="4984" />
        <node id="4323" />
</nodes>


I need to do a foreach on that, and then generate html code based on those ID's. The id's are ID's of Umbraco Nodes.

Please help.

Thanks,
Jeremy
drobar
Posted: Friday, November 14, 2008 9:09:02 PM

Rank: Umbracoholic

Joined: 9/8/2006
Posts: 1,831
Location: MA, USA
It is difficult to impossible to have one macro call another. Thus, I think you have two options:

1. Do the work you would have done in xslt right in the usercontrol. Anything you can do in an xslt macro you can do in the .net control. The entire umbraco api is at your disposal.

2. Make an aspx page that calls your control. Then, in your xslt macro, call that page with the umbraco.library:GetXmlByUrl() function and pass in the url of the aspx page.

I'd go for option 1, personally.

cheers,
doug.

MVP 2007-2009 - Percipient Studios
defsteph
Posted: Friday, November 14, 2008 11:08:36 PM

Rank: Newbie

Joined: 3/19/2008
Posts: 14
Location: Stockholm
jbrisko wrote:
Hey guys, I have a situation where I need to pass generated data from a C# user control, back into an xslt macro as a variable or some other way of acessing it. I'm having the c# user control pass back a set of nodes such as...

Code:

<nodes>
        <node id="4052" />
        <node id="4625" />
        <node id="4651" />
        <node id="4325" />
        <node id="4984" />
        <node id="4323" />
</nodes>


I need to do a foreach on that, and then generate html code based on those ID's. The id's are ID's of Umbraco Nodes.

Please help.

Thanks,
Jeremy


Is this something that could be returned by a custom library method rather than a usercontrol? You could have it return a XPathNodeIterator, and it would behave in the same way that GetXmlNodeById does. That way you could return the nodes in their entirety directly.

http://www.b-line.se/ - You one-stop-shop for great Hip-Hop Music.
drobar
Posted: Monday, November 17, 2008 4:35:35 PM

Rank: Umbracoholic

Joined: 9/8/2006
Posts: 1,831
Location: MA, USA
Just thought of another option! (don't you love umbraco's flexibility?!?)

3. Put the C# code into an xslt extension. Then your xslt macro can call your custom xslt extension just as easily as the built-in umbraco.library or exslt functions. The output from your extension is then available right within your xslt macro for any further processing.

cheers,
doug.

MVP 2007-2009 - Percipient Studios
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.