Home > .net 2.0, c# > ModalPopupExtender & Button (or anything) Events

ModalPopupExtender & Button (or anything) Events

February 27, 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: , ,

Categories: .net 2.0, c#
  1. JSimpson
    March 23, 2007 at 9:42 am

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

  2. mlange
    May 23, 2007 at 3:09 pm

    Thanks…removing that code works great.

  3. Frank
    June 12, 2007 at 2:57 am

    😀 !!! – 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!

  4. ronnel.santiago
    October 23, 2007 at 5:06 am

    very cool!

  5. Rogelio
    May 8, 2008 at 10:18 am

    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?

  6. July 24, 2008 at 3:11 pm

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

  7. September 19, 2008 at 7:30 am

    Zakarrakatelas!, Gracias chera’a!!!. That’s an expression I used a lot here in Paraguay, you don’t know how much you help me with this simplicity! Thanks again!

  1. June 4, 2007 at 10:44 am
Comments are closed.
%d bloggers like this: