Skip to content Skip to sidebar Skip to footer

Refresh Parent Dropdownlist From Popup In Asp.net C#

I have a dropdwnlist control in my parent page - ASP.NET C#, on click of button there is a popup opening to add new value to the control.

Solution 1:

Change your loadOptionLandlord as below

functionloadOptionLandlord(val,txt)
        {
            var opt = document.createElement("option");            
            var sCtrl = document.getElementById('<%= ddlLandlord.ClientID %>').options.add(opt);
            opt.text = txt;
            opt.value = val;
}

Solution 2:

can you check this function ?

functionloadOptionLandlord(val,txt)
        {
            // Those create element not needed and its a wrong // because you directly add option to select//var opt = document.createElement('<option value="'+ val +'">');// opt.innerText = txt;var sCtrl = document.getElementById('<%= ddlLandlord.ClientID %>');

            sCtrl.options[sCtrl.options.length] = newOption(txt, val, false, true);

        }

here is sample js to add option on drop-down JS BIN

Post a Comment for "Refresh Parent Dropdownlist From Popup In Asp.net C#"