Copied to clipboard

Flag this post as spam?

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


  • Neil Fenwick 86 posts 63 karma points
    Aug 06, 2010 @ 16:42
    Neil Fenwick
    0

    Macro caching and .NET databinding syntax

    ASP.NET 3.5

    Umbraco 4.0.3

    I've been trying to get a macro to cache its output, depending on the value of a variable that I set on an attribute of the macro

    1.

                <!-- Footer -->
                <div id="footer">
                    <div>
                        <umbraco:Macro ID="Macro1" Alias="[XSLT]FooterLinks" runat="server" customerType='<%# UmbracoLibrary.CustomerTypeContextManager.CustomerType  %>'></umbraco:Macro>
                        <p>
                        <umbraco:Macro Alias="[XSLT]FooterText" runat="server"></umbraco:Macro></p>
                      <span>&copy;&nbsp;<%= DateTime.Now.Year %></span>
                    </div>
                </div>

     

    For some reason the above does not work, even though if I do the following:

    2.

    <p><%= UmbracoLibrary.CustomerTypeContextManager.CustomerType  %></p>

    I do get a value output to the page.

    I have checked the cached values for the Macro on the umbraco Developer tab and the value for the customerType attribute is not part of the cache key, so it appears like it came through blank

     

    The CustomerTypeContextManager is a static class that is just accessing values in the Request context, like querystring, cookies etc.

    I would have gone for the following, but it appears not to work in that combination in Umbraco 4.0.3

    3.

    <umbraco:macro value="[@requestValue], [%cookieValue], [$pageVariable]" />

     

    I think even adding the spaces after the commas would break the last approach.

     

    Anyone got any ideas why approach no. 1. does not seem to work?

  • Neil Fenwick 86 posts 63 karma points
    Aug 06, 2010 @ 16:44
    Neil Fenwick
    0

    Ignore this topic - I think I have answered the question.

    I am not running the code above inside a <form runat="server"> and there are no datasources on the page.  DataBinding syntax does not apply here.

    Pity - workaround failed.  Still no straight forward native umbraco way to coalesce request, cookie and document type variables yet.

Please Sign in or register to post replies

Write your reply to:

Draft