Aperture
Aperture

Reputation: 2427

In Visual Studio C# ASP.NET, is there a way to auto generate an event handler?

Let's say you want to auto generate an event handler for a button click event. If you could switch to .aspx design view, you could find a little lightening symbol in the button's property panel, which contains all the events for the button. All you have to do is to double click on the click event to auto generate a click event handler. But the problems is buttons often are contained inside some other controls and it is therefore not possible to switch to the design view and locate the button. I had to hand write all the event handlers myself which is really tedious. Is there any good way to do this?

Upvotes: 1

Views: 3623

Answers (1)

fenix2222
fenix2222

Reputation: 4730

It is always better to write code in code-behind and it really is not that hard

protected void btn_Click(object sender, EventArgs e)
{

}

You could create a snippet for it in Visual studio, this way you just type snippet name and double tab.

Create custom code snippet in Visual Studio 2008

Try also double clicking on the button in the designer.

Upvotes: 2

Related Questions