1 Attachment(s)
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
Attachment 170197
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:
private void Form1_Load(object sender, EventArgs e)
{
button2.Click+=
}
I then hit Tab as prompted and got this:
csharp Code:
private void Form1_Load(object sender, EventArgs e)
{
button2.Click += Button2_Click;
}
private void Button2_Click(object sender, EventArgs e)
{
throw new NotImplementedException();
}
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.