Copied to clipboard

Flag this post as spam?

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


  • Fuji Kusaka 2203 posts 4220 karma points
    May 16, 2011 @ 07:57
    Fuji Kusaka
    0

    Rendering a .net userControl

    Hi,

    Can someone explain to me how do i get to render a userControl I created in Visual Studio?

    I already inserted the dll my marcos and XSLT.

    Now when viewing the Page content it is returning me

    <a id="basket_3_lnkbasket">Add to basket</a>

    Instead I want to be able to view a link to be able to Add products to my basket.

    Here is how i inserted my control in my XSLT

     

    <xsl:value-of
    select="umbraco.library:RenderMacroContent('&lt;?UMBRACO_MACRO
    macroAlias=&quot;cart&quot;
    runat=&quot;server&quot;&gt;&lt;/?UMBRACO_MACRO&gt;',
    '1115')"/>

    //fuji

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    May 16, 2011 @ 08:30
    Dirk De Grave
    0

    Fuji,

    it's really bad practise to render a user control using xslt, in fact, i think it's just not possible. Instead, you can always create a macro referecing your user control and put the macro onto your template.

     

    Hope this helps.

    Regards,

    /Dirk

  • Fuji Kusaka 2203 posts 4220 karma points
    May 16, 2011 @ 08:33
    Fuji Kusaka
    0

    Dirk,

    Thanks for pointing this out, I need to make a loop in there so how do i make this if am using only the macro?

    Do i need to make this in the userControl itself?

    Fuji

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    May 16, 2011 @ 08:42
    Dirk De Grave
    0

    yes, whatever you wanted to do using the xslt, you'll have to do this in c# code, probably making use of the nodeFactory to loop through your nodes. Here's a small code snippet to get you started:

    var node = new Node(1000);
    var childNodes = node.Children;
    foreach (var childNode in childNodes) {
      //do whatever you need to do here
    }

    Don't forget to add the relevant assemblies and using statements

    Hope this helps.

    Regards,

    /Dirk

  • Fuji Kusaka 2203 posts 4220 karma points
    May 16, 2011 @ 08:46
    Fuji Kusaka
    0

    Can i used

    <msxsl:script language="C#" implements-prefix="str"> 
     
    </msxsl:script>

    in my XSLT and loop everything in here instead of looping it in my userControl??

     

    //fuji


  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    May 16, 2011 @ 08:50
    Dirk De Grave
    0

    oh yes you can, but i thought there's some performance penalties using the inline script as it gets compiled each time you request some function from the inline script (not sure if this is still valid for the latest version, but guess it still is)

     

    Cheers,

    /Dirk

  • Fuji Kusaka 2203 posts 4220 karma points
    May 16, 2011 @ 08:52
    Fuji Kusaka
    0

    Well need to give it a try i know it works under version 4.5.1..

     

    I'll let you know how it works. Thanks Dirk

     

    //fuji


  • Fuji Kusaka 2203 posts 4220 karma points
    May 16, 2011 @ 09:03
    Fuji Kusaka
    0

     

    However is it possible to make a loop in a Template?..

     

    //fuji

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    May 16, 2011 @ 09:04
    Dirk De Grave
    0

    sure it is possible, just include the code snippet in <% %> syntax...

     

    Cheers,

    /Dirk

  • Fuji Kusaka 2203 posts 4220 karma points
    May 16, 2011 @ 09:06
    Fuji Kusaka
    0

     

    I will try this out....

     

    //fuji

Please Sign in or register to post replies

Write your reply to:

Draft