ModalPopupExtender & Button (or anything) Events
27 02 2007I’m sure this it out there if I’d Google it a bit more, but I had an issue where I had the ModalPopupExtender that prompted for “OK” after setting a few options. I do not like to include script in my MasterPages and wanted to use a bit of BusinessLogic in the code-behind. So, when they Click OK, I want it the button to run it’s Button_Click event, not the OnOkScript event of the Extender.
The ModalPopupExtender control:
<cc1:ModalPopupExtender ID=”mPopPrintClassReports” runat=”server” TargetControlID=”lnkPrintClassReports” PopupControlID=”pnlOuterPrintClassReports” PopupDragHandleControlID=”pnlInnerPrintClassReports” CancelControlID=”btnCancelClassReports” Drag=”false” DropShadow=”true”></cc1:ModalPopupExtender>
Notice anything in here?
The OkControlID is not specified. Yep… that’s the entire solution. To bypass the functionality of the Extender and use the object’s own event model, simply do not link the objects. I’m sure the same works for the CancelControlID as well.
Yeah, I felt not-so-smart after this… *sigh* Sure it’s not Monday?





Nice. Not published and yet necessary in order to utilize code-behind elements. Thanks.
Thanks…removing that code works great.
[...] this is to ensure that the Search and Attach Students buttons you see above are not hidden. More information about this here. One thing to point out: Attach Students and Cancel CANNOT be part of your User Control (and [...]
Google thanks!
very cool!
wow. I was in the same boat. what a waste of an hour. doesnt make sense to me. why make an OK button NOT do any server side code?
Great, thanks a lot….your a guru. Nothing to be proud of microsoft!