ModalPopUpExtender, Multiviews, and updatepanel

Last post 05-18-2007 2:27 AM by Raymond Wen - MSFT. 2 replies.

Sort Posts:

  • ModalPopUpExtender, Multiviews, and updatepanel

    05-14-2007, 1:50 PM
    • Loading...
    • Brainify
    • Joined on 05-09-2007, 7:23 PM
    • Posts 5

    Hi all,

    I have a major problem right now that I can't solve. Basically, I have an update panel which contains a Modalpopupextender displaying a multiview.

    When the modal popup comes up with the first view, the user enters some information and then clicks the next button switching to the second view. I have set the OkControlID of the modal popup to be a button the second view.

    Now because of the way mulitviews work, clicking the next button causes the page to refresh and the modal popup goes away. So to actually make the second view come up I have to cick on a button which display the modal popup again which then has the second view displayed.

    To avoid this issue, I've put the modal popup panel in an update panel so that switching from one view to another view causes no refreshes. This works fine. But when the popup goes to the second view, the ok button doesn't work anymore!

    I've discovered that the update panel actually causes the cientID of the ok button, in the second view, to change on refreshing it...and since I set the OKControlID of the modal popup to the ok button on the event page_load this never gets updated when the update panel refreshes....thus an OkControlID doesn't exists anymore (or work anymore) becuase the client ID is different for the ok button in the second view..

    I hope this all made sense...but I am realy stumped right now on what to do. I have been trying to find an event handler for the updatepanel so that the updatepanel updates it fires this event and i can set the OkControlID, but nothing is working right now...

     
    Any ideas anyone?

  • Re: ModalPopUpExtender, Multiviews, and updatepanel

    05-18-2007, 2:24 AM
    Answer

    Hi,

    This can be achieved via invoking the functions defined in the ModalPopControlExtender.

    The main idea is to change the OK control id via javascript.


        <script type="text/javascript">
       
        function changeID(newOkControlID)
        {
            var ext = $find("ModalPopupExtender1");
           
            if (ext._OkControlID) {       
                $removeHandler($get(ext._OkControlID), 'click', ext._okHandler);
                ext._okHandler = Function.createDelegate(ext, ext._onOk);
                ext._OkControlID = newOkControlID;
                $addHandler($get(ext._OkControlID), 'click', ext._okHandler);
            }
        }
        </script>

    You need to call it at the end of each partial postback, and pass in the new client id of the button in view 2.

    Hope this helps.

  • Re: ModalPopUpExtender, Multiviews, and updatepanel

    05-18-2007, 2:27 AM

    The above post uses private member of the extender control, and it's not a good pratice.

    May be you can first dispose the ext component, and then recreate one with parameters you need.

    Haven't tested yet, just for reference.

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