c# - Specific ListBox value always selected -


i using listboxfor user can select multiple values ,a user wants should 1 value selected ex:

listbox contains: id   category 1    2    b 3    c 4    d 5    general 

here general category should selected , user should not able change selected value listbox.

@html.listboxfor(model => model.selectedcategory, viewbag.listcategories multiselectlist, new { }) 

i using asp.net mvc 5

actually can rare scenario,one approach can use use jquery.if has solution in mvc helpers plz tell me other wise using jquery.

try using jquery

  $(document).ready(function () {        $('#selectedcategory').find('option[value="5"]').attr('selected','selected');   }); 

this works fine.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -