GThree
GThree

Reputation: 3500

How to generate control level events automatically in asp.net

I have worked in silverlight and in silverlight I can create control level events automatically on XAML, but I am unable to do that in .aspx page.

Following are the examples to give clear idea.

Silverlight: If I want to create a new event on TextBlock called KeyDown, silverlight gives me an option called "<New Event Handler>" which will automatically generate respected event in .cs file .

enter image description here

Asp.NET: If I want to create an OnClick event on button than I don't have any option.

enter image description here

If I go to design page where my button is located and do double click than event is populating on .cs page but I want to do that on source in .aspx page.

Am I missing something here? I think there shouldn't be any difference in this scenario but I am not sure why I am not getting auto event generate option.

I am using VS 2010 and .NET Framework 4

Upvotes: 0

Views: 51

Answers (1)

mason
mason

Reputation: 32694

VS 2010 doesn't auto create the event in ASP.NET. You can either manually create it, or upgrade to VS 2013 (which may be free depending on which version you want/are eligible for).

The event signature is often

protected void MyControlId_EventName(object sender, EventArgs e);

but of course you can look up the specifics on MSDN. A notable exception is some of the GridView event handlers.

Upvotes: 1

Related Questions