Results 1 to 2 of 2

Thread: How to list the other events in Global.asax in C#

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,794

    How to list the other events in Global.asax in C#

    When I was using VB.NET, it was listing all the events, I just had to click on the event, and it would automatically insert the code, but in C# I can't figure it out:

    For example I want to add code in the Session_Start, but the event is not listed

    Name:  Untitled.jpg
Views: 339
Size:  31.0 KB

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    107,648

    Re: How to list the other events in Global.asax in C#

    You can't use those drop-downs to create event handlers in C# but the code editor will still help you. I just tested this in a WinForms application project but it should work anywhere. Enter the type/reference and event name into your code and then enter += and the IDE should prompt you to add an event handler. In my test, I was adding a Click event handler for button2 so I entered button2.Click+= and was here:
    csharp Code:
    1. private void Form1_Load(object sender, EventArgs e)
    2. {
    3.     button2.Click+=
    4. }
    I then hit Tab as prompted and got this:
    csharp Code:
    1. private void Form1_Load(object sender, EventArgs e)
    2. {
    3.     button2.Click += Button2_Click;
    4. }
    5.  
    6. private void Button2_Click(object sender, EventArgs e)
    7. {
    8.     throw new NotImplementedException();
    9. }
    It uses code snippet functionality so the name of the new method is highlighted and you can just start typing to change the name in both locations. When you're happy with the name, hit Enter and you're good to go.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width