如何在点击一个按钮关闭网页的超链接或链接按钮点击?
如何关闭网页上的按钮/超链接/链接按钮的单击事件在C#,ASP.NET?
How to close a web page on the click event of button/hyperlink/link button in C#,ASP.NET ?
假设你正在使用的WinForms,因为它是当我开始C#你需要创建一个事件来关闭这个形式我做的第一件事。
Assuming you're using WinForms, as it was the first thing I did when I was starting C# you need to create an event to close this form.
假设你有一个叫myNewButton按钮。如果您双击它的WinForms设计师,你将创建一个事件。之后,你只需要使用 this.Close
Lets say you've got a button called myNewButton. If you double click it on WinForms designer you will create an event. After that you just have to use this.Close
private void myNewButton_Click(object sender, EventArgs e) {
this.Close();
}
这应该是它。
And that should be it.
这个唯一的理由不工作是,你的事件是由按键分离。但它应该创建新的事件,如果旧的是,当你在的WinForms设计师按钮双击不再连接。
The only reason for this not working is that your Event is detached from button. But it should create new event if old one is no longer attached when you double click on the button in WinForms designer.