.NET Zone is brought to you in partnership with:

I am former Microsoft MVP for Visual C# having 9 Year of experience in Microsoft.NET And other Microsoft Technologies. Please fill free to contact me at www.dotnetjalps.com Jalpesh is a DZone MVB and is not an employee of DZone and has posted 57 posts at DZone. You can read more from them at their website. View Full User Profile

Using Visual Studio 2012: Event Handler Generation

07.08.2012
| 4407 views |
  • submit to reddit
This post will be a part of Visual Studio 2012 feature series.

There are lots of new features there in visual studio 2012. Event handler generation is one of them. In earlier version of visual studio there was no way to create event handler from source view directly.  Now visual studio 2012 have event handler generation functionality.

So if you are editing an event view in source view intellisense will display add new event handler template and once you click on it. It will create a new event handler in the cs file. It will also put a eventhandler name against event name so you don’t need to write that.

So, let’s take a simple example of button click event so once I write onclick attribute their smart intellisense will pop up
.
Event handler generation in visual studio 2012 - What's new in visual studio 2012

Now once you click on <Create New Event> It will create event handler in .cs file like following.


Event Handler in asp.net with visual studio 2012 - What's new in visual studio 2012

It will also put submitButton_Click on onClick attribute.

Create event new handler in visual studio 2012 - new feature of visual studio 2012

Hope you liked it. Stay tuned for more. Till then happy programming..
Published at DZone with permission of Jalpesh Vadgama, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)