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
    Jun 05, 2010 @ 23:15
    Paul Sørensen
    0

    Content Picker as parameter to .Net User control

    Hi

    I have created a User Control where I need the URL of another page on my site.

    I have wrapped the control in a macro and added a parameter of type int called MemberResultPageUrl, which is also the name of the property in my usercontrol.

    In my document I have created a property - memberResultPageURL - of type Content Pciker. My template looks like this:

        <umbraco:Macro MemberResultPageUrl="[#memberResultPageURL]" Alias="msResultList" runat="server">
        </umbraco:Macro>

    If I call the page with the debug parameter - ?umbDebugShowTrace=true - setting the property is not listed

        <umbraco:Macro MemberResultPageUrl="123" Alias="msResultList" runat="server">
        </umbraco:Macro>

    I get this

    loadUserControl    Usercontrol added with id 'MsResultList_3'   
    macro.loadControlProperties    Property added 'MemberResultPageUrl' with value '123'   

    What am I doing wrong here?

    /Paul S

     

  • Tim 1193 posts 2675 karma points MVP 4x c-trib
    Jun 06, 2010 @ 10:42
    Tim
    0

    In the code you've pasted in, the Macro appears to have set the property to 123? Which I'm guessing is the node id of the page. You can use the GetNiceUrl() function from the umbraco library to turn that into a URL.

  • Bert 128 posts 251 karma points
    Jun 06, 2010 @ 16:59
    Bert
    0

    a contentpicker, nodepicker ... etc give back the ID of the node that is selected.

    Your macro recieves an ID, this will be passed to your user control. Depending on your needs you can ask the url, document ... of the selected node by different api methods.

    Here you will use the GetNiceUrl()function which requires the id of the document as a parameter.

  • Paul Sørensen 304 posts 650 karma points
    Jun 07, 2010 @ 23:09
    Paul Sørensen
    0

    Hi Tim

    The 123 is the id of the node and I use the GetNiceUrl in my UC to get the URL and it works fine. The problem is that I want a ContentPicker in my document to provide the value 123.

    The way it is now it's hardcoded - I want to be able to change it using a ContentPicker-.

     - Bert, you're describing exactly what I want but the problem is that the value doesn't get passed from the ContentPicker to the UC - but if I insert a hardcoded value in the template - 123 - it works fine.

    Paul S

Please Sign in or register to post replies

Write your reply to:

Draft