Select options added server side rendering as undefined

I’m writing an app with the scheduler for ASP.NET in VB.NET
Here’s the server side code for a lightbox select that I’m adding. The options are pulled from the db and into an iEnumerable of lightboxSelectionOption by the shared helper method in the code block bellow.

        Dim ddlLocation As LightboxSelect = New LightboxSelect("offLocations", "Office Location")
        ddlLocation.MapTo = "location"
        ddlLocation.Height = 30
        ddlLocation.AddOptions(DropDownListHelpers.CreateLocationsDropDownListOptions)
        Scheduler.Lightbox.Add(ddlLocation)

When I run the app, the options in the select have “undefined” as their keys and labels. It works when the options are added separately with the AddOption() method, but not the method the takes an enumerable of options.

Hi!

I’ve confirmed the bug, I also get undefined list items when options are added using AddOptions method, using LightboxSelectOption items.

The issue happens only when you use an IEnumerable of LightboxSelectOption objects, options are loaded correctly if you pass them using anonymous classes:
So workaround is to use anonymous classes for options collection:

c#:

var select = new LightboxSelect("offLocations", "AddOptions AnonymousClass");
select.MapTo = "location";
select.Height = 30;

select.AddOptions(new List<object>
{
     new {key = 1, label = "first" },
     new {key = 2, label = "second" }
});

vb.net:


    Dim select2 = New LightboxSelect("offLocations", "AddOptions AnonymousClass")
    select2.MapTo = "location"
    select2.Height = 30
    select2.AddOptions(New List(Of Object) From {
        New With {Key
            .key = 1, Key
            .label = "first"
        },
        New With {Key
            .key = 2, Key
            .label = "second"
        }
    })
1 Like