How to close a window on click event using c#?

Hello Experts.

I have a button on a web form that I would like to close the window when clicked.  I am using VS2012 and c#.

I am attempting to use the following:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace case
    public partial class frm1_new_case : System.Web.UI.Page
    {        protected void Page_Load(object sender, EventArgs e)
        private void btn_close_Click(object sender, EventArgs e)

Open in new window

Unfortunately I keep getting the following error:

'case.frm1' does not contain a definition for 'Close' and no extension method 'Close' accepting a first argument of type 'case.frm1' could be found (are you missing a using directive or an assembly reference?)

Am I missing a using directive?

Any help would be greatly appreciated.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AndyAinscowFreelance programmer / ConsultantCommented:
Is this what you want?
Lokesh B RDeveloperCommented:

Only in Windows Forms you have the CLOSE() method.

In web application you cannot close the web page. Instead you can redirect to the new Page or create a POP UP using jQuery/Javascript/ModalPopExtender using AJAX.




Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ferguson_jeraldAuthor Commented:
Thanks Andy, but that doesn't work.  Lokesh, the Response.Redirect didn't accomplish what I needed either.  However, I was able to find the answer on another site.  The following does exactly what I needed:

String x = "<script type='text/javascript'>window.opener.location.href='**Your new url of new page after completing test**';self.close();</script>";
ScriptManager.RegisterClientScriptBlock(this.Page,this.Page.GetType(), "script", x,false);


Open in new window

AndyAinscowFreelance programmer / ConsultantCommented:
Thanks, but as my suggestion didn't work I've asked all the points should go to the other expert.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.