Quantcast
Channel: DevNet Questions
Viewing all articles
Browse latest Browse all 8901

Inheriting from Kentico.Content.Web.Mvc.MultipleChoiceComponent

$
0
0
Is it possible to inherit from Kentico.Content.Web.Mvc.MultipleChoiceComponent that allows me to to dynamically generate my own checkbox items, but still use the built in markup that just using MultipleChoiceComponent alone would use?For example, instead of using this for a widget property, which only allows static values:[EditingComponent(MultipleChoiceComponent.IDENTIFIER)] [EditingComponentProperty(nameof(MultipleChoiceProperties.DataSource), @item1;Item 1\r\nitem2;Item 2@)] public string SelectedItems { get; set; } I'd like to create something this:[assembly: RegisterFormComponent(CustomMultipleChoiceComponent.IDENTIFIER, typeof(CustomMultipleChoiceComponent), @Custom multi select list@)] public class CustomMultipleChoiceComponent : MultipleChoiceComponent { public new const string IDENTIFIER = @CustomMultipleChoiceComponent@; protected override IEnumerable@HtmlOptionItem@ GetHtmlOptions() { yield return new HtmlOptionItem { Text = @Foo@, Value = @foo@ }; yield return new HtmlOptionItem { Text = @Bar@, Value = @bar@ }; } } But I don't want to have to re-create the view that renders out the checkbox list.Is it possible?

Viewing all articles
Browse latest Browse all 8901

Trending Articles