Tutorial :Where is Page Event List in C#?


I'm VB.NET developer and recently I start working on C# projects.

In VB code behind page within VS.NET (2005/2008) when select "Page" on the LHS dropdownlist, the RHS ddl automatically display the list of all the page events that are available (Page_Load, Page_Init, Page_PreRender ...) So to write the code for Page_Init event, you simply just select the Paeg_Init and vs.net will generate the Page_Init method code.

How do you do this in C#? I know that you can manually write the methods code: protected void Page_PreRender(object sender, EventArgs e) {


But isn't it handy to have the page event list available to choose?


Try typing override and then space. Visual Studio will filter the intellisense window to display only virtual methods from the base class.

Also if you select one of these, Visual Studio will stub out the override method for you.


View your Web Form in Design view. From the View menu choose Component Designer. Now look in the Properties window. You should now see the Events icon with a list of events. Double-click on one to stub out an event handler for the page event.


Here are the code snippets for those events.


I've been pulling my hair out for months over this too. Page events and control events are both missing, and impossible to guess what the default args list is.

I found it's easiest to keep a test project in VB.net ready with the dependencies that my C# project uses. I drop an object on to the page and select the event I need in the code-behind, and then copy that into the C# project.

But you're right--it's an annoying that they wouldn't give this feature to both, even in 2010RC...

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »