How to show a AJAX modalpopup by javascript and set a button onclick attribute in the same javascript function
Is it possible to show a AJAX modalpopup by javascript and at the same time set the onclick attribute for a button in the modalpopup, I can´t get it to work and i think it´s because the modalpopup div has display: none when doing the call to the javascript function, am I right?
To clarify why I'm setting the button onclick attribute to another javascript function that doing __doPostback is because i don´t think it´s possible to set a buttons CommandName and CommandArgument by javascript.
function showModalPopupAndSetCancelButtonOnlick() {
$find('mpeLo开发者_开发知识库gMessagePopupBehavior').show();
$get('btnLogMessageCancel').onclick = function() { __doPostBack('btnLogMessageCancel','testArgument'); };
}
Now it works! Couldn´t do this because the function is in a external javascript file.
var button = $get(<%= btnLogMessageCancel.ClientID %>);
Instead it worked if i apply the clientID manually in my function
function popupLogMessage(controlId, controlArguments) {
$find('mpeLogMessagePopupBehavior').show();
var button = $get('ctl00_ContentPlaceHolder1_btnLogMessageCancel');
button.onclick = function() { __doPostBack(controlId, controlArguments); };
}
精彩评论