简体   繁体   中英

ASP.NET 3.5 AJAX Control ToolKit PopupControlExtender

I'm trying to generalize the .add_hiding for PopupControlExtender by passing some arguments, but for some reason its not working.

function onPageLoad() {
            var modalPopup = $find('txbCliente_PopupControlExtender');
            modalPopup.add_hiding(onHidingPopUp('cblCliente','txbCliente'));
        }
        function onHidingPopUp(cblId, txbID) {
            var cbl = document.getElementById(cblId);
            var optionsIds = cbl.getElementsByTagName('input');
            var optionsLabels = cbl.getElementsByTagName('label');
            var varios = false;
            var txb = document.getElementById(txbID);
            var text = "";

            for (var i = 0; i < optionsIds.length; i++) {
                if (optionsIds[i].checked && varios) {
                    text = "Mútiplos Valores.";
                    break;
                }
                else if (optionsIds[i].checked && !varios) {
                    varios = true;
                    text = optionsLabels[i].textContent;
                }
            }

            txb.value = text;
        }

You pass a result of calling onHidingPopUp('cblCliente','txbCliente') , not the function itself to the add_hiding method. If you want to pass predefined arguments to the function, wrap it in another function:

modalPopup.add_hiding(function() {
    onHidingPopUp('cblCliente','txbCliente')
});

If you only had one parameter, you could also use the MS Ajax Function.createCallback extension:

modalPopup.add_hiding(Function.createCallback(onHidingPopUp, 'cblCliente'));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM