Reputation: 981
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?
Upvotes: 4
Views: 9876
Reputation: 21
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.
Upvotes: 2
Reputation: 73
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.
Upvotes: 7
Reputation: 161773
I've been able to do this with ReSharper, but I've been using it for so long that I don't recall whether Visual Studio has this capability natively.
Upvotes: 1