ASP.NET, Events, and C#

N

Nathan Sokalski

I am an ASP.NET developer and am trying to learn more about C# as a
codebehind language. When writing the code to handle an event, is there an
easy way to have Visual Studio 2005 automatically place the eventhandler's
signature in the code (including the parameters)? When using VB.NET, all you
had to do was select the control from the left dropdown and the event from
the right dropdown, and there you go! But C# not only makes you add an
attribute in the *.aspx file, but to the best of my knowledge, you need to
manually type the signature for the eventhandler. I would think that Visual
Studio would have added something to make implementing the events a little
bit easier. Is there something I am missing, or has Visual Studio just not
added this feature to C# yet? Thanks.
 
M

Michael Nemtsev [MVP]

Hello Nathan,

If you double click on the form control you should have the event handler
signature for them in your code behind.
Moreover, you can open property window and select which event you want to
use

---
WBR,
Michael Nemtsev [Microsoft MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


NS> I am an ASP.NET developer and am trying to learn more about C# as a
NS> codebehind language. When writing the code to handle an event, is
NS> there an easy way to have Visual Studio 2005 automatically place the
NS> eventhandler's signature in the code (including the parameters)?
NS> When using VB.NET, all you had to do was select the control from the
NS> left dropdown and the event from the right dropdown, and there you
NS> go! But C# not only makes you add an attribute in the *.aspx file,
NS> but to the best of my knowledge, you need to manually type the
NS> signature for the eventhandler. I would think that Visual Studio
NS> would have added something to make implementing the events a little
NS> bit easier. Is there something I am missing, or has Visual Studio
NS> just not added this feature to C# yet? Thanks.
NS>
 
S

Stan

I am an ASP.NET developer and am trying to learn more about C# as a
codebehind language. When writing the code to handle an event, is there an
easy way to have Visual Studio 2005 automatically place the eventhandler's
signature in the code (including the parameters)? When using VB.NET, all you
had to do was select the control from the left dropdown and the event from
the right dropdown, and there you go! But C# not only makes you add an
attribute in the *.aspx file, but to the best of my knowledge, you need to
manually type the signature for the eventhandler. I would think that Visual
Studio would have added something to make implementing the events a little
bit easier. Is there something I am missing, or has Visual Studio just not
added this feature to C# yet? Thanks.

Hi Nathan

As a former VB coder (where events are exposed via the drop-down list
at the top of the code editor) you may not be aware that the propeties
window has two views (I know it took me a while to find it) one for
properties and one for events..

Look at the top of the properties window and among the buttons you'll
see one with a sort of lightning strike icon. Click that an you see a
list of events instead of properties. Click on any entry and the code
outline for the chosen event will be created automatically. To go back
to properties view click the button to the left of the events view
button (one which looks like a two column page of text).

HTH
 
C

Cowboy \(Gregory A. Beamer\)

Two ways I can think of

1. Double click on the control - this is very useful for the default event
handler (click for button, etc.)
2. Click on the control in design and go to the properties window. Click on
the lightning bolt and find the event you wish to handle. Type in a handler
and it will be created for you.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

********************************************
| Think outside the box! |
********************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top