Copied to clipboard

Flag this post as spam?

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


  • rasb 162 posts 218 karma points
    Dec 23, 2009 @ 12:16
    rasb
    0

    .Net User Control property values based on current page

    Hi guys,

    I have created a User Control that has a number of properties that controls the layout and behavior of this control.

    The basic functionality is to dynamically create a form, where the user can interact with certain information on the site. I create form fields based on two comma separated string properties, and I would like to pass information in through the template based on the current page.

    One example is, that I would like to pass in the name of the page and the values of two properties I have defined in my Document Type. These values should be part of the comma separated string that also holds some "hard coded" values defined when creating the template. 

    I have an example of what I would like to do here:

    <umbraco:Macro 
      FieldList="name,car,driver,trackToLoad" 
      FieldNames="Name,Car,Driver,Track" 
      FieldValues=",,,{PageName}" 
      Alias="rallyForm" 
      runat="server"></umbraco:Macro>

    I want to pass in the Page Name in the Values list, but this is not necessarily always the Page Name. It could be something else like this:

     

    <umbraco:Macro 
      FieldList="name,car,driver,driver2,trackToLoad" 
      FieldNames="Name,Car,Driver,Competing Driver,Track" 
      FieldValues=",,{@DriverId},," 
      Alias="rallyForm" 
       runat="server"></umbraco:Macro>

     

    Where I would like to pass in a Document Type Property to the same control but in a different Template.

    Any thoughts on how to do this best... or should I redesign the properties completely?

    Thanks in advance, and Happy Holidays!
    RasB

    Using umbraco v 4.0.3 (Assembly version: 1.0.3625.27276)

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Dec 23, 2009 @ 12:39
    Dirk De Grave
    0

    Hi rasb,

    Have a look at this wiki page on how to pass document properties from your macro to the user control.

     

    Hope this helps.

    Regards,

    /Dirk

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Dec 23, 2009 @ 12:41
    Sebastiaan Janssen
    0

    Maybe Dirks article about parameter chaining could be useful here as well. But it sounds like you're putting too much responsibility into one macro call though.. 

  • rasb 162 posts 218 karma points
    Dec 23, 2009 @ 14:10
    rasb
    0

    Hi Dirk and Sebastian,

    Very interesting articles indeed! But it unfortunately not exactly what I am looking for. The parameter chaining syntax looks like clashes with my own syntax. I am not looking for chaining, but rather multiple values and hard coded text in the macro properties. Så when I enter:

    inputParameter="[#title], [$otherTitle], My default title"

    I would like that to pass in the value "title, otherTitle, My default title" rather than just one of them. I am going to try with a semicolon separated list instead of a comma separated.

    Thanks for the input guys!

  • rasb 162 posts 218 karma points
    Dec 27, 2009 @ 14:07
    rasb
    0

    Hi Guys,

    I ended up sending in the NodeId of the page, and then parsing properties myself. Reading values like that doesn't work apparently.

    Thanks for the input guys,
    RasB

Please Sign in or register to post replies

Write your reply to:

Draft