Copied to clipboard

Flag this post as spam?

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


  • Vijay 30 posts 47 karma points
    Nov 26, 2009 @ 18:11
    Vijay
    0

    Unable to render user control via Macro in XSLT

    Guys,

      I am having problems rendering a user control in xslt.  My ascx user control has a linked button that takes in a text value and renders that as the text of the linked button (I created a public property for this).

      When I associate this user control to a macro and try to render the macro in xslt, it renders the user control, but does not create the link, nor does it set the text property of the link button correctly.  It does shows the default text value in plain text.  But when I call the macro directly in a template it works perfectly. 

       Any quick help on this will be greatly appreciated.

    Here is the xslt code (My user control contains public properties foreach of the parameters and it uses "TEXT1" as the linked button's text):

        <xsl:variable name="LinkMacro">
            <xsl:value-of select="string('&lt;?UMBRACO_MACRO macroAlias=&quot;TicketTypesNavigate&quot; ID1=&quot;')" />
            <xsl:value-of select="$ID1"/>
            <xsl:value-of select="string('&quot; ID2=&quot;')" />
            <xsl:value-of select="ID2"/>
            <xsl:value-of select="string('&quot; ID3=&quot;')" />
            <xsl:value-of select="$ID3"/>
            <xsl:value-of select="string('&quot; TEXT1=&quot;')" />
            <xsl:value-of select="TEXT1"/>
            <xsl:value-of select="string('&quot; &gt;&lt;/?UMBRACO_MACRO&gt;')"/>
        </xsl:variable>


        <xsl:value-of select="$LinkMacro"/>
        <xsl:value-of select="umbraco.library:RenderMacroContent($LinkMacro, number($currentPage/@id))" disable-output-escaping="yes"/>&nbsp;&nbsp;

  • dandrayne 1138 posts 2262 karma points
    Nov 26, 2009 @ 18:24
    dandrayne
    0

    AFAIK, You can only use renderMacro() in xlst with xslt macros, not .net macros.  I also don't think you can insert macro include codes directly in your xslt.

    Dan

  • Vijay 30 posts 47 karma points
    Nov 26, 2009 @ 18:56
    Vijay
    0

    Thanks Dan for your quick reply.

    Now my question is this:  How do I render this linked button user control via xslt on my page?  I cant do it using templates because, I am iterating through xml to render the contents of this page.

    I hope there is another way I can do this.

  • dandrayne 1138 posts 2262 karma points
    Nov 26, 2009 @ 22:25
    dandrayne
    0

    Hows about using xslt to decide which template to render, or whether or not to render a template?  You could then insert the contents of a template containing your usercontrol depending on a condition.  something like

    <xsl:choose>
    <xsl:when test="yourcondition">
    <xsl:value-of select="umbraco.library:RenderTemplate($pageId,$templateId)" disable-output-escaping="yes" />
    </xsl:when>
    <xsl:otherwise>
    <xsl:value-of select="umbraco.library:RenderTemplate($pageId,$templateId)" disable-output-escaping="yes" />
    </xsl:otherwise>
    </xsl:choose>

    Dan

  • Vijay 30 posts 47 karma points
    Nov 27, 2009 @ 00:00
    Vijay
    0

    Let me try that Dan, as soon as I can get to my work computer.  Also I need to look up how to send parameters to that template.  My user control requires parameters to work correctly.  If you know off the top of your head how to send parameters let me know, otherwise no worries I can look it up.

     

    Thanks again!

     

     

  • Vijay 30 posts 47 karma points
    Nov 27, 2009 @ 04:27
    Vijay
    0

    ok..I am not able to find anywhere how to pass parameters to the Render Template call from my xslt.  As I mentioned my user control expects 4 parameters to be sent in.

    Also is the $pageId the node id of the current page? how do i get the template id?

    Thanks in advance :)

  • Casey Neehouse 1339 posts 483 karma points MVP 2x admin
    Nov 27, 2009 @ 08:25
    Casey Neehouse
    0

    Hi Vijay,

    Rendering the template will not solve your problem, as the render template does not maintain form data.  Simply, your best bet is to use the umbraco Node Factory and write a user control rather than use XSLT.

    There are ways around the render template, but at present, there is nothing built in.

    A modified macro control could be used to parse the xslt results and parse additional macros as it processes the data.  Something similar to what the item control does now.

  • Casey Neehouse 1339 posts 483 karma points MVP 2x admin
    Nov 27, 2009 @ 08:31
    Casey Neehouse
    0

    Vijay,

    You can iterate the XML in your template, as they are .NET master pages (in v4).  You can access the XML and use Node Iterators to select and traverse your nodes.  I would use a user control to keep some separation of style and coding.

     

  • Vijay 30 posts 47 karma points
    Nov 29, 2009 @ 01:31
    Vijay
    0

    Casey,

      Thank you very much for your ideas.  I will try them as soon as I get a chance.  The reason I am going through all these reasons is so that I can avoid query strings.

    My architecture is simple:

    Page 1 ---> send parameters to Page 2 via query strings --> Page 2 uses these values ---> Navigates to page 3 ----> Page 3 uses certain values  from that query string to display

    So if some user messes around with the query string on Page 2 then it messes the display on page 3.

Please Sign in or register to post replies

Write your reply to:

Draft