Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to close a web page on a button click, a hyperlink or a link button click? [closed]

How can we provide a hyperlink or button to close a web page ?

like image 608
ranbir Avatar asked May 23 '10 07:05

ranbir


3 Answers

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.

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.

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.

like image 167
MadBoy Avatar answered Oct 16 '22 11:10

MadBoy


To close a windows form (System.Windows.Forms.Form) when one of its button is clicked: in Visual Studio, open the form in the designer, right click on the button and open its property page, then select the field DialogResult an set it to OK or the appropriate value.

like image 23
Frederic Heem Avatar answered Oct 16 '22 11:10

Frederic Heem


double click the button and add write // this.close();

  private void buttonClick(object sender, EventArgs e)
{
    this.Close();
}
like image 20
HMcompfreak Avatar answered Oct 16 '22 11:10

HMcompfreak