jquery - Viewstate not working on Bootstrap multiselect in WebForms -


i have webforms application generates dynamic controls in page_init method. 1 of controls htmlselect control populate dynamically items. when renders on page, run ususal jquery code sets control checkbox next each list item.

        $("select[id*='team_filter']").multiselect({           nonselectedtext: 'all',           numberdisplayed: 1,           nselectedtext: 'selected',           allselectedtext: 'all'         }); 

the user checks items , posts page.

on post back, on page_load event check selected properties of items using code:

            htmlselect ctrl = (htmlselect)this.findcontrolrecursive("team_filter_1");                             var firstgame = ctrl.items.findbyvalue("game_1").selected;             var secondgame = ctrl.items.findbyvalue("game_2").selected; 

what's strange when user checks multiple options, first 1 returns true on page_load, rest return false. looks viewstate other checked items don't returned server.

here have in page_init, remember these dynamic controls, have put them in init:

                htmlselect teamfilter = new htmlselect();                 teamfilter.id = "team_filter_" + studioid;                 teamfilter.attributes.add("class", "col-md-9");                 teamfilter.attributes.add("multiple", "true");                  listitem listitem = new listitem("all " + studioname, "studio_" + studioid);                 listitem.attributes.add("data-type", "studio");                 teamfilter.items.add(listitem);                  listitem = new listitem("all games", "game_0_" + studioid);                 listitem.attributes.add("data-type", "game");                 teamfilter.items.add(listitem); 

can try setting multiple property on htmlselect true

teamfilter.multiple = true; 

Comments

Popular posts from this blog

symfony - TEST environment only: The database schema is not in sync with the current mapping file -

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -