ModalPopupExtender and TargetControlID Event

Last post 09-12-2007 7:47 AM by sbogus. 5 replies.

Sort Posts:

  • ModalPopupExtender and TargetControlID Event

    02-16-2007, 4:33 PM
    • Loading...
    • dsmith
    • Joined on 06-30-2006, 2:50 PM
    • Memphis, TN
    • Posts 4

    Greetings,

     As always, my apologies if this question has been answered in the past (searches against various forums and development sites yielded no answers.)

    My setup is such - I have a ModalPopupExtender that has a PopupControlID which points to a Panel with content. The TargetControlID is a Button. All of this exists within an UpdatePanel (for transparent event-catching and handling).

    The problem with my setup lies herein - I have conditional instructions I need processed before the ModalPopupExtender displays the content in the content Panel. To that end, the Button which triggers the display of the ModalPopup, has a server-side "click" event bound to it. However, the Button's "click" event is never processed on the server-side (insofar as breakpoints are indicative of processing.)

    I believe that the ModalPopupExtender is the culprit - removing the Button as the TargetControlID allows the Button's "click" event to be processed normally on the server-side.

    Is there any way that the ModalPopupExtender can pass to the server the original event for the TargetControlID ("click" event for the Button, in this case)?

     
    My apologies if there's some glaring, obvious solution I'm missing, but I'm at my wit's end with this particular setup. I've tried indirect event postbacks, JavaScript "fake button" hacks, and other solutions with no results.

  • Re: ModalPopupExtender and TargetControlID Event

    02-16-2007, 5:42 PM
    • Loading...
    • dark_angle
    • Joined on 11-30-2006, 5:13 PM
    • Posts 28

    I have the same question too !

    waiting for the answer :)

  • Re: ModalPopupExtender and TargetControlID Event

    02-16-2007, 9:44 PM
    • Loading...
    • Jason Hill
    • Joined on 04-23-2006, 3:39 AM
    • Sydney, Australia
    • Posts 476
  • Re: ModalPopupExtender and TargetControlID Event

    09-12-2007, 7:24 AM
    • Loading...
    • akaKlen
    • Joined on 10-07-2004, 7:17 AM
    • Posts 41

    Sorry, I couldn't find the answer from the provided link on the question of this topic. Anyone has the answer of how to force LinkButton to postback from within a ModalPopup?

    Thanks.

  • Re: ModalPopupExtender and TargetControlID Event

    09-12-2007, 7:41 AM
    • Loading...
    • akaKlen
    • Joined on 10-07-2004, 7:17 AM
    • Posts 41

    For now, I use the following javascript:

    if (!ClientScript.IsClientScriptBlockRegistered("OKClick"))
    {
     
    ClientScript.RegisterClientScriptBlock(this.GetType(), "OKClick",
       
    "<script type=\"text/javascript\">function onModalOK() { " +
        ClientScript.GetPostBackEventReference(lbtnOk,
    string.Empty) +
       
    " }</script>"
      );
    }

    and set ModalPopupExtender properties like this:

    OkControlID="lbtnOk" OnOkScript="onModalOK()"

    Filed under: ,
  • Re: ModalPopupExtender and TargetControlID Event

    09-12-2007, 7:47 AM
    • Loading...
    • sbogus
    • Joined on 05-29-2007, 11:47 AM
    • Europe, Germany
    • Posts 77

    Hi akaKlen,

    In fact the thread posted by Jason Hill really answers your question, but I'll try to explain it more simple and understandable.

    The problem by the postbacks and the AJAX extenders with TargetControlID properties is the fact that if the target page control issues a postback, it dismisses the ASP.NET page (and thus the control controled by the extender itself) and you'll need to re-create/re-display the extended control on the postback load of the page. Because of this the target controls normally are not allowed to issue a postback and they operate entirely on the client side of the page. There's possibility to issue a postback from a targeted contro by attaching new behavior event handler for the showing event (look at the add_showing method of the ModalPopup Behavior object). In this additional event handler you could call the __doPostBack global function. However, the results of such action are not always desired...

    The method which Jason has described in the referenced thread is better - you make a "hidden" link button control which serves as Target Control and then from the server-side event handlers of your buttons you can call the Show method of the ModalPopupExtender page control. Thus you'll have the server-side processing you need first and after that you display the modal popup. But remember - the popup will display after the page postback.

     

    Kind regards,

    sbogus.


     

Page 1 of 1 (6 items)
Microsoft Communities
Page view counter