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.
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
Focusing on the hide, I have this js code below and an anchor tag that calls it. This is in the web dialog window. FWIW, my webdialogwindow is another aspx page. JS produces null ever time for WebDialogWindow1 even if i do this.parent.$find or just $find.
<script language="javascript">function closeDialogWindow(){ $find('WebDialogWindow1').hide();}</script>
and an anchor tag that calls it.
<
a href="#" OnClick="closeDialogWindow();"><span style="font-size:x-small;">Cancel</span></a>