ASP.Net & jQuery - closing a popup

1.8k views Asked by At

I want to close a ShadowBox popup when the user clicks a button. The popup is showing a separate page in an Iframe. This works fine with a clients-side event on the Cancel button control, e.g.

OnClientClick="javascript:parent.Shadowbox.close();"

The Ok button, however, has a server-side event, because data needs to be saved. When I define both an OnClick and the OnClientClick handler from above, the IFrame is closed and the server-side event handler never fires.

I tried to remove the OnClientClick event handler from the markup and to use the ClientScriptManager to accomplish this, as in

Page.ClientScript.RegisterStartupScript(this.GetType(),
  "Close", "parent.Shadowbox.close();", true);

Apparently because the buttons are in an UpdatePanel, the script does not get registered, and it does not appear in the Reponse stream. The IPanel stays open.

How can I do this?

1

There are 1 answers

4
womp On BEST ANSWER

When you're using the MS AJAX controls, you need to register your scripts with the ScriptManager, not ClientScript.