My macro gets rendered (I can see my form) but it seems that no codebehind is executed. Neither in Page_Load nor in OnPreRender. When I render this macro within a template, everything works as expected.
I also tried to use the new syntax to include my macro like I did in my template:
I think you might be missing a form with property runat="server" around the macro.. That would cause the usercontrol to just render the HTML, but the functionality will never be executed.
Another strange thing is that my form validators are showing the errormessage when the page is rendered. Normally they are shown after I submit my form and missed a field... Also this problem does not exists when I include this macro in my template.
You cannot run a usercontrol macro inside xslt. It is not supported.
I don't know the exact technical reason, but as you corretly write, the codebehind will not be registered because the output from XSLT is simply a string, and not a .net template.
Also, as you can see, the method is only called RenderMacroContent, which is actually what it does. It just renders the output, and does not register any logic behind it.
I don't know if it is possible to solve it, but it will not work in the current version of umbraco. I am guessing that it has something to do with the time when the xstl macros are rendered. Until the xslt is rendered, the asp.net runtime knows nothing about the usercontrol you are inserting, and if the usercontrol rendering has already completed, then it will never be picked up.
RenderMacroContent problem
I want to render a usercontrol within my xslt. So I tried:
My macro gets rendered (I can see my form) but it seems that no codebehind is executed. Neither in Page_Load nor in OnPreRender.
When I render this macro within a template, everything works as expected.
I also tried to use the new syntax to include my macro like I did in my template:
But with no success - nothing is displayed in this case.
The only reference to RenderMacroContent I found was this wiki page. Maybe it's outdated.
I think you might be missing a form with property runat="server" around the macro.. That would cause the usercontrol to just render the HTML, but the functionality will never be executed.
You're right, I missed it. Now I tried:
But nothing changes. Still the same problem.
Another strange thing is that my form validators are showing the errormessage when the page is rendered. Normally they are shown after I submit my form and missed a field...
Also this problem does not exists when I include this macro in my template.
You cannot run a usercontrol macro inside xslt. It is not supported.
I don't know the exact technical reason, but as you corretly write, the codebehind will not be registered because the output from XSLT is simply a string, and not a .net template.
Also, as you can see, the method is only called RenderMacroContent, which is actually what it does. It just renders the output, and does not register any logic behind it.
I see, that is obvious. I'll try to find another solution for my problem.
Thank you.
Aha! That's good to know Morten. I try to prevent using macro's from XSLT anyway, it's kinda ugly.
im having the same problem .. what could it be? it must be some kind of settings or environment thing ..
I don't know if it is possible to solve it, but it will not work in the current version of umbraco. I am guessing that it has something to do with the time when the xstl macros are rendered. Until the xslt is rendered, the asp.net runtime knows nothing about the usercontrol you are inserting, and if the usercontrol rendering has already completed, then it will never be picked up.
is working on a reply...