It is my experience that programmatically adding parameters to a Macro only works if you create the Macro from your codebehind. As I recall it has something to do with the buildup of the Macro and when its loading/calling. Its been a while since I debugged it, but here is what worked for me:
I have a standard <asp:PlaceHolder ID="macroContainer" runat="server"/> on my .ascx page. And I create the Macro in my codebehind:
I have this inside protected override void OnPreRender(EventArgs e) I can't remember if it makes a difference to place it inside the protected void Page_Load(object sender, EventArgs e) but try it out. Should work in both Masterpages and Usercontrols.
Thanks for your replies. I've had a read through and had a chat with a friend and I think I may be going around this in the wrong way.
I've accepted Peters answer as the solution because it answers the question but i think i'm going to change the architecture of what i'm doing so there is no reliance on the master page.
The user control should probably be autonomous so I think I'll change it so it goes and gets the information it self rather than relying on the master page sending it the information.
Pass public variable in MasterPage to User Control Macro
Hi
I'm looking to send a public variable in a masterpage code behind to an umbraco macro.
I've tried the suggestions on the advanced paramiters wiki page but can't get any of them to work.
Could someone tell me if this is possible or do I need to include the usercontrols using the standard asp.net way?
Cheers
Jon
Hi Jon
Have a look at Code Expression builder. There is a good writeup on how to use this with Umbraco on the Delphic Sage site.
http://www.delphicsage.com/home/blog.aspx/d=854/title=Code_Expressions_to_Programmaticify_Your_Umbraco_Site
It should sort out your codebehind variable woes.
Hi Jon,
It is my experience that programmatically adding parameters to a Macro only works if you create the Macro from your codebehind. As I recall it has something to do with the buildup of the Macro and when its loading/calling. Its been a while since I debugged it, but here is what worked for me:
I have a standard <asp:PlaceHolder ID="macroContainer" runat="server"/> on my .ascx page. And I create the Macro in my codebehind:
I have this inside protected override void OnPreRender(EventArgs e)
I can't remember if it makes a difference to place it inside the protected void Page_Load(object sender, EventArgs e) but try it out. Should work in both Masterpages and Usercontrols.
- Morten
Morten,
You live and learn have had need in past to do this but was'nt quite sure how to do it, just voted up your post.
Regards
Ismail
Hey
Thanks for your replies. I've had a read through and had a chat with a friend and I think I may be going around this in the wrong way.
I've accepted Peters answer as the solution because it answers the question but i think i'm going to change the architecture of what i'm doing so there is no reliance on the master page.
The user control should probably be autonomous so I think I'll change it so it goes and gets the information it self rather than relying on the master page sending it the information.
Cheers
Jon
is working on a reply...