Copied to clipboard

Flag this post as spam?

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


  • Aron Gamble 63 posts 76 karma points
    Apr 28, 2009 @ 21:51
    Aron Gamble
    0

    Set a checkbox list item as checked using Action Handler

    Another newbie question...

    I'm trying to create an action handler that sets a particular checkbox list item as checked when a new page is created. All the available doc types have the checkbox list - i've got this working for a text box (setting a default line of text) but am struggling to get an object that represents my checkboxlist.

    This is how i'm trying to get the list:-

    umbraco.cms.businesslogic.property.Property p = documentObject.getProperty("memCats");

    I was thinking i need to cast it somehow or is it just case of setting the value of p to be a string with the item text in it ie:-

    p.Value = "option1"

    Any help would be great.

    Thanks in advance.

    Aron

  • Richard Soeteman 4054 posts 12927 karma points MVP 3x
    Apr 28, 2009 @ 22:12
    Richard Soeteman
    0

    Hi Aron,

    According to the source it is mapping on text values so it should be working like you described. Allthough I see that a comma is always added after the value as you can see in the code snippet below. so maybe you can try p.Value = "option1,"

    [code]_text += li.Value + ",";[/code]

    If you are useing Action Handlers you must save the document yourself to see the changes (it is a post save).

    In Umbraco V4 Events are the way to go to hook into actions. Checkout chapter 6 of this book how to wire it up. I have a few examples on my weblog also. The event you need is Document.BeforeSave

    Hope it helps you,

    Richard

  • Aron Gamble 63 posts 76 karma points
    Apr 29, 2009 @ 18:27
    Aron Gamble
    0

    Thanks for that, setting the value is exactly how it works but I used the item ID and not the text and now it's working perfectly!

    Thanks again.

    Aron

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies