How to close an active web form

I have a popup box with a textarea control. The user enters text into the textarea and then clicks a button (on the popup, not the parent) to save.

What I want is to have the sqldatasource do an update (I know how to do that) and then close the popup window. I have tried several metthods that I found on the web but nothing seems to work. Any Ideas?
Who is Participating?
cubaman_24Connect With a Mentor Commented:
You can call it from a button. In Page_Load:

cancelButton.Attributes.Add("onclick", "window.close();");

Without button too:
string strscript  = "<script language=javascript>window.close();</script>";
If (!ClientScript.IsStartupScriptRegistered("clientScript")) {
      ClientScript.RegisterStartupScript(Page.GetType(), "clientScript", strscript);

Best regards.
To close the current window, in javascript, you can use self.close ();
lizziesboyAuthor Commented:
That doesn't seem to work. Plus the question was how to run code in the codebehind and then close the window all from one click of a button on the popup.
lizziesboyAuthor Commented:
Mea Culpa. I had "return false;" in the function. (I copied this piece of code from somewhere else. However it asks if I want to close the window. Can I close it without this confirmation?
Not through the code behind... Because its not a user-initiated action.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.