0

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

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

You're right. I just did a quick test in VS 2012 where I can see that option. In my opinion this sucks but anyways I found the solution so thank you for your help.
@Robinhood I agree it's inconvenient. But there's very few reasons to be sticking with older versions of VS, as they rarely drop support for old frameworks in newer versions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.