ModalPopupExtender & Button (or anything) Events

27 02 2007

I’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?

Tags: , ,


Actions

Information

7 responses to “ModalPopupExtender & Button (or anything) Events”

23 03 2007
JSimpson (09:42:32) :

Nice. Not published and yet necessary in order to utilize code-behind elements. Thanks.

23 05 2007
mlange (15:09:57) :

Thanks…removing that code works great.

4 06 2007
Creating a Lookup Modal Popup « Ramblings of the Sleepy… (10:44:44) :

[...] 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 [...]

12 06 2007
Frank (02:57:34) :

:D !!! - I have been looking for this cool trick. I tempted and tried to use client callback but it wasn’t close to what I want!

Google thanks!

23 10 2007
ronnel.santiago (05:06:13) :

very cool!

8 05 2008
Rogelio (10:18:54) :

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?

24 07 2008
PostJavaGuru (15:11:29) :

Great, thanks a lot….your a guru. Nothing to be proud of microsoft!

Leave a comment

You can use these tags : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>