Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1495
Dialog Window
posted

How can I update an asp update panel from my dialog window and close the dialog window?  Can I do this in the code behind?  I need a sample. 

Thanks in advance.

Parents
No Data
Reply
  • 19308
    Suggested Answer
    posted

    You can do it in the code behind, or in JavaScript.  Either way has it's advantages/disadvantages.  UpdatePanel can't be refreshed via client-side without a 'hack'.  Posting the entire page back to the server, just to hide the dialog negates having the update panel there in the first place though. 

    My recommendation, do this on the client-side.  You can show and hide the WebDialogWindow through the client-side API.  It's actually rather straight forward.  Add a button to your dialog window, and one to your UpdatePanel, and hook up the button in the WebDialogWindow's onclientclick event.  When the button is clicked, call the WebDialogWindow's hide function (webDialogWindow1.hide())  and then call the other button's click event. So if the button you put in the UpdatePanel was button2 your javascript function would be something like

    function OnButtonClick(){
    $find("webDialogWindow1").hide();
    $get("button2").click();
    }

    By calling the second button's click event, you will force it to perform a postback, which will be captured by the UpdatePanel, and turned into an AJAX callback.

    -Tony

Children