I write a view page with asp core and use select2 for my combo box .when use disable this line code work good:
$('select').prop("disabled", true);
but it disable and not readonly. i want readonly. in readonly value save but in disable valu not save and posted null value to controller. in select2 document with this(
$('select').select2('readonly',true);
OR
$('select').prop('readonly',true);
can readonly. but it can not work for me. why?? :-(
I found a solution for my problem with select2 readonly.
First, add this CSS:
Now to do readonly, I must add this jQuery code:
And to remove the readonly attribute, I must add this: