I hacked one into the code for ModalPopupBehavior.js just to show how easy it is to dig right into the toolkit and add what ever you want to it. Don't try this on production. just so I could have an ShowIt DontShowIt functions to turn it on and off at will.
I use these to scripts to turn the modalpopup on and off.
<script type="text/javascript">
function dan1(x) {
var j = $find('Button1_ModalPopupExtender');
j.DontShowIt(); // j.ShowIt() to turn it back on...
}
function dan2(x) {
var j = $find('Button1_ModalPopupExtender');
j.ShowIt(); // j.ShowIt() to turn it back on...
}
</script>
I moded up the ModalPopupBehavior.js and put it int the root folder of my website.
// Properties
this._DontShow = null; // dont show property add in the properties section
//added this code right about the _onShow function.
get_DontShow: function() {
if (this._DontShow == null) {
return true;
}
else {
return this._DontShow;
}
},
DontShowIt: function() {
this._DontShow = false;
},
ShowIt: function() {
this._DontShow = true;
},
//changed this code...
_onShow: function(e) {
/// <summary>
/// Handler for the target's click event
/// </summary>
/// <param name="e" type="Sys.UI.DomEvent">
/// Event info
/// </param>
if (!this.get_element().disabled && this.get_DontShow()) {
this.show();
e.preventDefault();
return false;
}
},
Then I force the modalpopup extender to use the script.
<cc1:ModalPopupExtender ID="Button1_ModalPopupExtender" runat="server"
PopupControlID="Panel1" BackgroundCssClass="modalBackground"
OkControlID="ok" CancelControlID="cancel"
OnCancelScript="dan1(this);" ScriptPath="ModalPopupBehavior.js"
DynamicServicePath="" Enabled="True" TargetControlID="Button1">
</cc1:ModalPopupExtender>
Have fun with your ajax control tool kit I do.