When you edit a simple page in the design view, you can add an event on most components by simply double-clicking the relevant event. This does the binding and generates the function declaration in the codebehind for you.
In larger projects where the pages are complex, the design view can be extremely slow. Is there a way to quickly generate the codebehind stubs directly from the .aspx
source?
Just begin typing the code to create your component.
For example, this is the code to add a button to your .aspx file:
<asp:Button ID="ButtonAction" class="btn panel-black" runat="server" Text="" OnClick="Function_Name_Here" />
When you get to typing the function name for the OnClick method...
for example, this part of the code:
OnClick="Function_Name_Here"
... Visual Studio will display a little pop-up window with the option to "<create new event>
".
Select this option and the codebehind event handler stub will be generated for you.
In the markup view the Properties window is still available: you may have it hidden.
When it's shown and the cursor is in the markup for a particular control, you get that control's properties and events like you would in Design view. Similarly, in the event tab you can double-click the event (i.e Click) to automatically generate an empty declaration in code and hook up the event without ever having to go into the Design view.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With