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):
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.
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.
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
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.
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?
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.
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.
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.
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('<?UMBRACO_MACRO macroAlias="TicketTypesNavigate" ID1="')" />
<xsl:value-of select="$ID1"/>
<xsl:value-of select="string('" ID2="')" />
<xsl:value-of select="ID2"/>
<xsl:value-of select="string('" ID3="')" />
<xsl:value-of select="$ID3"/>
<xsl:value-of select="string('" TEXT1="')" />
<xsl:value-of select="TEXT1"/>
<xsl:value-of select="string('" ></?UMBRACO_MACRO>')"/>
</xsl:variable>
<xsl:value-of select="$LinkMacro"/>
<xsl:value-of select="umbraco.library:RenderMacroContent($LinkMacro, number($currentPage/@id))" disable-output-escaping="yes"/>
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
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.
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
Dan
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!
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 :)
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.
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.
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.
is working on a reply...