N2 radiobuttonlist attribute

N2 radiobuttonlist attribute


A radio button list attribute is much simpler to implement then the checkbox list attribute, as only one option is being persisted.

UpdateEditor checks whether the radio button list has a selected value. If so, it sets the selected item of the radio button list.

UpdateItem sets the selected value for the content item.

AddEditor has its data source set to a selection of content items, and adds the a radio button list to the editor interface.


public class EditableRadioListAttribute : AbstractEditableAttribute
{
    public override void UpdateEditor(N2.ContentItem item, Control editor)
    {
        RadioButtonList rbl = editor as RadioButtonList;
        if (rbl != null)
        {
            rbl.SelectedValue = item[this.Name].ToString();
            if (rbl.Items.FindByValue(item[this.Name].ToString()) != null)
            {
                rbl.Items.FindByValue(item[this.Name].ToString()).Selected = true;
            }
        }
    }

    public override bool UpdateItem(N2.ContentItem item, Control editor)
    {
        RadioButtonList rbl = editor as RadioButtonList;
        string itemID = rbl.SelectedValue;
        item[this.Name] = itemID;
        return true;
    }

    protected override Control AddEditor(Control container)
    {
        RadioButtonList rbl = new RadioButtonList();
        var items = N2.Find.Items
            .Where.Type.Eq(typeof(TestItem))
            .Filters(new NavigationFilter())
            .Select();
        foreach (TestItem i in items)
        {
            rbl.Items.Add(new ListItem(i.Title, i.ID.ToString()));
        }
        container.Controls.Add(rbl);
        return rbl;
    }
}

And here is how to use the radio button list attribute


[EditableRadioListAttribute(Title = "Item")]
public virtual string Item
{
    get { return (string)(GetDetail("Item", "")); }
    set { SetDetail("Item", value, ""); }
}

Below is an even simpler way of a creating a radio button list attribute using the N2 EditorModifier


[Editable("Template", typeof(RadioButtonList), "SelectedValue", 5, DataBind = true)]
[EditorModifier("DataSource", new string[] {"Template 1", "Template 2", "Template 3"})]
public virtual string Template
{
            get { return (string)(GetDetail("EmailTemplate") ?? "Template 1"); }
            set { SetDetail("EmailTemplate", value); }
}

In fact, this can also be used for a dropdown list.

123 comments (Add your own)

1. Calvinjes wrote:
online prescription
viagra without doctor prescription
where to buy viagra
viagra without doctor prescription
prescriptions online

Mon, March 25, 2019 @ 11:58 PM

2. Gregorynow wrote:
viagra without a doctor prescription walmart
viagra without doctor prescription judpharmacy
viagra without a doctor prescription walmart
generic viagra without a doctor prescription
viagra without a prescription

Tue, March 26, 2019 @ 12:12 PM

3. JoshuaReile wrote:
the best online casino for mac online roulette canada paypal online casinos accepts residents site gambling internet blackjacks

Wed, March 27, 2019 @ 11:43 AM

4. wrote:
I don't even know the way I ended up right here, but I believed this post was once good.
I do not realize who you might be however definitely you are
going to a famous blogger in case you aren't already.
Cheers!

Fri, May 10, 2019 @ 6:58 PM

5. viagra wrote:
Hello!

Tue, May 28, 2019 @ 7:26 AM

6. viagra_cheap wrote:
Hello!

Tue, May 28, 2019 @ 2:35 PM

7. viagra wrote:
Hello!

Wed, May 29, 2019 @ 12:17 PM

8. cheap_viagra wrote:
Hello!

Wed, May 29, 2019 @ 9:09 PM

9. cialis wrote:
Hello!

Thu, May 30, 2019 @ 4:35 AM

10. cialis wrote:
Hello!

Thu, May 30, 2019 @ 11:23 AM

11. cialis_generic wrote:
Hello!

Thu, May 30, 2019 @ 11:38 PM

12. cialis_online wrote:
Hello!

Sat, June 1, 2019 @ 12:46 PM

13. wild_viagra wrote:
Hello!

Sat, June 1, 2019 @ 1:20 PM

14. viagra_online wrote:
Hello!

Sun, June 2, 2019 @ 11:54 AM

15. online_viagra wrote:
Hello!

Mon, June 3, 2019 @ 12:53 AM

16. online_viagra wrote:
Hello!

Mon, June 3, 2019 @ 4:55 AM

17. online_viagra wrote:
Hello!

Tue, June 4, 2019 @ 11:43 PM

18. order_cialis wrote:
Hello!

Wed, June 5, 2019 @ 5:31 AM

19. generic_viagra wrote:
Hello!

Thu, June 6, 2019 @ 2:29 PM

20. men wrote:
Hello!

Sun, June 9, 2019 @ 1:39 AM

21. cheap_viagra wrote:
Hello!

Sun, June 9, 2019 @ 2:51 PM

22. viagra wrote:
Hello!

Sun, June 9, 2019 @ 8:04 PM

23. buy_viagra wrote:
Hello!

Mon, June 10, 2019 @ 3:55 AM

24. discount_cialis wrote:
Hello!

Mon, June 10, 2019 @ 7:28 AM

25. viagra wrote:
Hello!

Mon, June 10, 2019 @ 11:19 AM

26. viagra_cheap wrote:
Hello!

Tue, June 11, 2019 @ 11:42 PM

27. viagra_cheap wrote:
Hello!

Wed, June 12, 2019 @ 2:52 AM

28. buy_viagra wrote:
Hello!

Thu, June 13, 2019 @ 8:55 AM

29. generic_viagra wrote:
Hello!

Thu, June 13, 2019 @ 12:33 PM

30. viagra wrote:
Hello!

Sun, June 16, 2019 @ 12:22 AM

31. buy_cialis wrote:
Hello!

Mon, June 17, 2019 @ 5:42 PM

32. of wrote:
Hello!

Tue, June 18, 2019 @ 3:15 PM

33. online_cialis wrote:
Hello!

Wed, June 19, 2019 @ 2:40 AM

34. cialis_online wrote:
Hello!

Wed, June 19, 2019 @ 9:45 PM

35. buy_viagra wrote:
Hello!

Fri, June 21, 2019 @ 12:32 AM

36. viagra_online wrote:
Hello!

Sat, June 22, 2019 @ 5:57 AM

37. viagra_generic wrote:
Hello!

Mon, June 24, 2019 @ 7:41 AM

38. viagra wrote:
Hello!

Mon, June 24, 2019 @ 4:19 PM

39. viagra_cheap wrote:
Hello!

Mon, June 24, 2019 @ 9:25 PM

40. viagra wrote:
Hello!

Tue, June 25, 2019 @ 1:26 AM

41. viagra_cheap wrote:
Hello!

Tue, June 25, 2019 @ 9:58 AM

42. cialis wrote:
Hello!

Wed, June 26, 2019 @ 1:08 PM

43. cialis wrote:
Hello!

Wed, June 26, 2019 @ 4:13 PM

44. buy_viagra wrote:
Hello!

Wed, June 26, 2019 @ 8:19 PM

45. cheap_cialis wrote:
Hello!

Thu, June 27, 2019 @ 4:02 PM

46. viagra_online wrote:
Hello!

Sat, June 29, 2019 @ 3:16 AM

47. cheap_viagra wrote:
Hello!

Sun, June 30, 2019 @ 12:35 AM

48. online_viagra wrote:
Hello!

Sun, June 30, 2019 @ 9:25 AM

49. cialis wrote:
Hello!

Sun, June 30, 2019 @ 6:22 PM

50. canadian_cialis wrote:
Hello!

Mon, July 1, 2019 @ 4:47 AM

51. online_viagra wrote:
Hello!

Mon, July 1, 2019 @ 4:09 PM

52. cialis wrote:
Hello!

Tue, July 2, 2019 @ 3:02 AM

53. buy_viagra wrote:
Hello!

Thu, July 4, 2019 @ 8:00 PM

54. buy_cialis wrote:
Hello!

Fri, July 5, 2019 @ 2:32 PM

55. cialis_cheap wrote:
Hello!

Sat, July 6, 2019 @ 10:25 PM

56. buy_viagra wrote:
Hello!

Sun, July 7, 2019 @ 3:34 AM

57. buy_viagra wrote:
Hello!

Sun, July 7, 2019 @ 9:34 AM

58. discount_cialis wrote:
Hello!

Mon, July 8, 2019 @ 3:54 AM

59. buy_viagra wrote:
Hello!

Mon, July 8, 2019 @ 4:35 AM

60. buy_cialis wrote:
Hello!

Tue, July 9, 2019 @ 11:55 AM

61. cialis wrote:
Hello!

Fri, July 12, 2019 @ 2:24 AM

62. cheap_viagra wrote:
Hello!

Fri, July 12, 2019 @ 4:22 AM

63. buy_viagra wrote:
Hello!

Fri, July 12, 2019 @ 8:20 AM

64. cialis wrote:
Hello!

Sat, July 13, 2019 @ 1:52 AM

65. cheap_viagra wrote:
Hello!

Sat, July 13, 2019 @ 3:08 AM

66. viagra wrote:
Hello!

Mon, July 15, 2019 @ 12:35 PM

67. cheap_cialis wrote:
Hello!

Tue, July 16, 2019 @ 12:12 AM

68. cialis wrote:
Hello!

Tue, July 16, 2019 @ 2:58 PM

69. canadian_cialis wrote:
Hello!

Tue, July 16, 2019 @ 9:14 PM

70. buy_cialis wrote:
Hello!

Wed, July 17, 2019 @ 7:30 AM

71. viagra wrote:
Hello!

Thu, July 18, 2019 @ 2:55 AM

72. cialis_canada wrote:
Hello!

Thu, July 18, 2019 @ 3:36 AM

73. cialis_online wrote:
Hello!

Thu, July 18, 2019 @ 8:06 AM

74. buy_viagra wrote:
Hello!

Sat, July 20, 2019 @ 8:30 AM

75. buy_cialis wrote:
Hello!

Mon, July 22, 2019 @ 3:10 AM

76. cialis wrote:
Hello!

Mon, July 22, 2019 @ 8:11 AM

77. viagra_online wrote:
Hello!

Tue, July 23, 2019 @ 12:49 PM

78. viagra_generic wrote:
Hello!

Sat, July 27, 2019 @ 5:48 AM

79. viagra wrote:
Hello!

Sat, July 27, 2019 @ 5:37 PM

80. viagra wrote:
Hello!

Sat, July 27, 2019 @ 7:02 PM

81. cialis wrote:
Hello!

Sat, July 27, 2019 @ 8:01 PM

82. cialis wrote:
Hello!

Sat, July 27, 2019 @ 8:23 PM

83. discount_cialis wrote:
Hello!

Sat, July 27, 2019 @ 8:56 PM

84. viagra wrote:
Hello!

Sun, July 28, 2019 @ 4:21 AM

85. cialis_generic wrote:
Hello!

Sun, July 28, 2019 @ 8:36 AM

86. viagra wrote:
Hello!

Sun, July 28, 2019 @ 9:44 AM

87. buy_viagra wrote:
Hello!

Sun, July 28, 2019 @ 10:46 AM

88. cialis wrote:
Hello!

Sun, July 28, 2019 @ 11:17 AM

89. buy_viagra wrote:
Hello!

Sun, July 28, 2019 @ 4:29 PM

90. generic_cialis wrote:
Hello!

Sun, July 28, 2019 @ 9:35 PM

91. super wrote:
Hello!

Mon, July 29, 2019 @ 4:44 AM

92. buy_viagra wrote:
Hello!

Mon, July 29, 2019 @ 4:44 AM

93. generic_cialis wrote:
Hello!

Mon, July 29, 2019 @ 2:30 PM

94. buy_viagra wrote:
Hello!

Mon, July 29, 2019 @ 9:33 PM

95. generic_cialis wrote:
Hello!

Mon, July 29, 2019 @ 10:12 PM

96. generic_cialis wrote:
Hello!

Mon, July 29, 2019 @ 10:21 PM

97. wrote:
I could not resist commenting. Well written! nuova Maglia Psg RobbyWill magliette calcio poco prezzo KishaEver

Thu, August 1, 2019 @ 5:26 AM

98. online_viagra wrote:
Hello!

Fri, August 2, 2019 @ 6:43 AM

99. generic wrote:
Hello!

Fri, August 2, 2019 @ 6:01 PM

100. viagra wrote:
Hello!

Fri, August 2, 2019 @ 8:54 PM

101. cialis wrote:
Hello!

Sat, August 3, 2019 @ 2:57 AM

102. buy_viagra wrote:
Hello!

Wed, August 7, 2019 @ 8:22 AM

103. generic wrote:
Hello!

Wed, August 7, 2019 @ 1:15 PM

104. cialis_canada wrote:
Hello!

Wed, August 7, 2019 @ 5:37 PM

105. buy_viagra wrote:
Hello!

Fri, August 9, 2019 @ 12:51 AM

106. buy_viagra wrote:
Hello!

Sat, August 10, 2019 @ 12:52 PM

107. wrote:
online generic viagra
viagra generic
sildenafil citrate 100 mg

http://www.genericviagrakart.com/generic-viagra.aspx
viagra

http://www.genericviagrakart.com/sildenafil-citrate.aspx
sildenafil citrate 100 mg

Sun, August 11, 2019 @ 12:50 PM

108. viagra_canada wrote:
Hello!

Wed, August 14, 2019 @ 6:15 PM

109. viagra wrote:
Hello!

Wed, August 14, 2019 @ 6:16 PM

110. cialis wrote:
Hello!

Thu, August 15, 2019 @ 3:15 PM

111. viagra wrote:
Hello!

Fri, August 16, 2019 @ 3:05 AM

112. viagra wrote:
Hello!

Fri, August 16, 2019 @ 3:23 AM

113. wrote:
I like what you guys are up also. Such intelligent work and
reporting! Keep up the excellent works guys I've incorporated you
guys to my blogroll. I think it will improve the
value of my web site :).

Sun, August 18, 2019 @ 8:32 PM

114. wrote:
I like what you guys are up too. Such intelligent work and reporting!
Carry on the excellent works guys I've incorporated you guys to my blogroll.

I think it'll improve the value of my website :).

Mon, August 19, 2019 @ 2:45 AM

115. wrote:
Hi there very nice website!! Guy .. Excellent .. Wonderful ..
I will bookmark your web site and take the feeds also? I am satisfied to seek out a lot of helpful information right here in the publish, we need develop more techniques on this regard, thanks for
sharing. . . . . .

Mon, August 19, 2019 @ 6:44 AM

116. viagra_cheap wrote:
Hello!

Mon, August 19, 2019 @ 7:47 AM

117. wrote:
Whats up very nice web site!! Man .. Excellent .. Wonderful ..
I will bookmark your web site and take the feeds also?
I'm glad to find numerous helpful info here within the submit,
we want work out more techniques in this regard, thanks
for sharing. . . . . .

Mon, August 19, 2019 @ 8:40 AM

118. wrote:
If some one wishes expert view concerning blogging and site-building after that i recommend him/her to pay a quick visit this weblog,
Keep up the good work.

Mon, August 19, 2019 @ 10:40 AM

119. cialis wrote:
Hello!

Mon, August 19, 2019 @ 11:30 AM

120. wrote:
Everyone loves what you guys are up too. This type of clever work and exposure!
Keep up the amazing works guys I've you guys to our blogroll.

Mon, August 19, 2019 @ 11:43 AM

121. wrote:
Terrific work! This is the kind of info that should
be shared across the net. Disgrace on Google for
not positioning this publish higher! Come on over and visit my website .
Thank you =)

Mon, August 19, 2019 @ 12:44 PM

122. wrote:
I believe you have remarked some very interesting points, thanks for the post.

Mon, August 19, 2019 @ 7:43 PM

123. wrote:
Way cool! Some extremely valid points! I appreciate you penning
this post and the rest of the site is also very good.

Tue, August 20, 2019 @ 3:18 PM

Add a New Comment


code
 

Comment Guidelines: No HTML is allowed. Off-topic or inappropriate comments will be edited or deleted. Thanks.