Copied to clipboard

Flag this post as spam?

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


  • Paul Sørensen 304 posts 650 karma points
    Mar 13, 2011 @ 00:35
    Paul Sørensen
    0

    Numeric parameter to macro

     

    Hi

    I'm trying to create a slideshow using xslt, butI have a problem
    passing the numeric value height to the macro

           <umbraco:Macro MediaRoot="number([#MediaRoot])" 
                             height="number([#height])" 
                             width="[#width]" 
                             class="[#class]" 
                             Alias="SlideshowImagesList" 
                             runat="server">
              </umbraco:Macro>

    I get this error . also without the number()

    Parser Error Message: Cannot create an object of type 'System.Web.UI.WebControls.Unit' from its string representation 'number([#height])' for the 'Height' property.

    Height is defined as number in the macro - the input comes from a
    document where it is defined as numeric.

    What is wrong here?

    Paul S 

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Mar 13, 2011 @ 01:36
    Chriztian Steinmeier
    0

    Hi Paul,

    You're using an XPath function (number()) within an ASP.NET tag - that won't work.

    You can do the cast within the XSLT file if needed (typically not needed), e.g.:

    <xsl:variable name="mediaRoot" select="number(/macro/MediaRoot)" />

    /Chriztian 

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Mar 13, 2011 @ 01:39
    Chriztian Steinmeier
    2

    Oh - my bad... forgot one very annoying thing: You can't use "width" or "height" as names for Macro parameters because they clash with some built in .NET stuff.

    Use with a prefix, like "imgWidth" and "imgHeight" and it'll work (still shouldn't use number() within the attributes, though)

    /Chriztian

  • Paul Sørensen 304 posts 650 karma points
    Mar 13, 2011 @ 10:18
    Paul Sørensen
    0

    Thanks Chriztian

    That was the solution!

              <umbraco:Macro MediaRoot="[#MediaRoot]" 
                             ImageHeight="[#height]" 
                             ImageWidth="[#width]" 
                             Class="[#class]" 
                             Alias="SlideshowImagesList" 
                             runat="server">
              </umbraco:Macro>

    This works

    Thanks
    /Paul S

Please Sign in or register to post replies

Write your reply to:

Draft