# Add an Event

Once you have opened the designer and added a button, it's time to add a click event to the button. This even will be triggered whenever the user clicks on the button.

There are two ways to add this:

1. By double-clicking on the button
2. By selecting the button, clicking on the event (lightning bolt) icon, and double-clicking on the click event

Either way, you will end up with the Page1.cs file open and the following code:

```csharp
private void button1_Click(object sender, System.EventArgs e)
{

}
```

This is the function that is called whenever the button is clicked. We can add some code so that an Alertbox is displayed whenever the user clicks the button:

```csharp
private void button1_Click(object sender, System.EventArgs e)
{
    AlertBox.Show("Button Clicked");
}
```

Run the program by clicking on this button at the top of Visual Studio:

<figure><img src="/files/5eWxsIK60yrabzBoZYtq" alt=""><figcaption></figcaption></figure>

Note that if you click on the dropdown menu, there are several options you can change:

You can change the web browser to Firefox, Google Chrome or Microsoft Edge

<figure><img src="/files/s8UoodEBLBhq4YfhMbjt" alt=""><figcaption></figcaption></figure>

You can change the framework that the project is running on

<figure><img src="/files/ymxFsyT0oYDncDnDdAlm" alt=""><figcaption></figcaption></figure>

Once the program is running, click the button. It will look like this:

<figure><img src="/files/FbWd4E1WRCvMF4I0B0QD" alt=""><figcaption></figcaption></figure>

Note that by default, the url will be localhost:5000 when running from Visual Studio


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.learnwisej.net/wisej.net-tutorial/first-steps-with-wisej.net/add-an-event.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
