Create a new project in Visual Studio 2010 (SharePoint –> 2010 –> Visual Web Part), call it VisualWebPartExample and press ok
The SharePoint Customization Wizard opens. Specify the desired target site (in my case called http://s22102) and select Deploy as a farm solution.Then press finish Visual Studio creates for you a project customized for the SharePoint development. It adds automatically packaging and feature settings and an example Visual Web Part.
Expand VisualWebPart1
Double click VisualWebPartExampleControl.ascx
Add a Label from control box, it should be called Label1
Put html <br /> after to put button on next line
Change the text of Label1 to “Hello WebPart”
Add a button from control box, it should be called Button1
Double click Button1, it should create a Button1_click method
Inside the Button1_Click menthod type Label1.Text = "Event triggered";