Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • mhutter 9 posts 29 karma points
    Oct 02, 2010 @ 02:25
    mhutter
    0

    Acces UserControl Property

    Is there anyway to access/inject a value from a usercontrol into a place where an xslt macro can use it?  I am able to get the usercontrol and the macro on the same page, but I can't figure out how to "hand off" the XPathNodeIterator to the xslt macro.  The method to get the data is somewhat complicated and really needs the functionality of the usercontrol to create the filter.  I was originally thinking I'd just be able to access the user control's property using a lib extension, but I guess I'm a little stumped.

    Thanks,

    Mike

  • Jonas Eriksson 930 posts 1825 karma points
    Oct 03, 2010 @ 04:22
    Jonas Eriksson
    0

    Hi Mike,

    if your usercontrol does not have user interaction I would go for creating an Xslt extension static cs-function instead, and call that from your Xslt.

    If it does have user interaction things get a bit trickier. Could still need that extension then, but you would need to control when the Xslt run. Using umbraco.library.RenderMacroContent it's possible to render a Xslt within a Ascx. (Only works if they are at the same place on the page obviously).

    Regards,

    Jonas

  • mhutter 9 posts 29 karma points
    Oct 04, 2010 @ 04:21
    mhutter
    0

    It does have user interaction, so I can't really go to an extension...

    So how would that work?  I guess I still don't see how I can "pass" the value from a control to the xslt.

    Thanks,

    Mike

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Oct 04, 2010 @ 08:47
    Sebastiaan Janssen
    0

    That would be pretty difficult indeed, wouldn't you be better off just doing it all in the usercontrol? 

    Otherwise you could probably put the data in a session object and create an xslt extension to read the session object.. but that's hacky.

  • Gerben 41 posts 136 karma points
    Oct 04, 2010 @ 09:22
    Gerben
    0

    Passing values from a user control marco to an xslt macro on the same page is somehow problamatic, as far as I know.

    This is basically because of the sequence in run-time execution of both macros in the Umbraco page life cycle. In my experience (correct me if I am wrong) all XSLT macrso are first executed and rendered. Then, all user control events (such as mouse clicks or other user interaction) are fired and dealt with. So, in that way, it is not possible to pass a value that has been changed by user interaction from the user control to the XSLT, (since the XSLT is already rendered at that time).

    I know of two solutions for this:

    • As suggested: use usercontrols for both (for display as well as change of data). Again: watch the sequence of exections for both controls!
    • Do a page refresh after the change of data. This allows the XSLT to render again with the changed data.


    And: instead of using a session object to pass values between user controls / XSLT extentions, use the page.items property. http://msdn.microsoft.com/en-us/library/system.web.ui.page.items.aspx These variables only live during the rendering of one page instead of session variables that have a heavier performance and memory footprint.

Please Sign in or register to post replies

Write your reply to:

Draft