Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Where are the event handlers in VS 2008

Posted on 2008-10-27
1
Medium Priority
?
1,593 Views
Last Modified: 2013-12-17
I have a project in VS 2008 that is using Master Pages.  I want to add an event handler to the Page_PreRender event, but I don't see it listed under any of the control properties.  If I select a panel control, it has a Panel_PreRender event, but there is no "Page" control to select.  The top item in the list is DOCUMENT, which does not have any events.  Thanks!
0
Comment
Question by:jvalescu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 16

Accepted Solution

by:
ororiole earned 2000 total points
ID: 22819460
Visual studio doesn't list the events for pages. I dont remember Visual Studio 2005 doing it either. And if you are looking for them under a control, you won't find them there. Controls expose their events, they have never exposed the Page events.

But here is what you do. You have two options.
1. In your <%@ Page directive on your markup page, add AutoEventWireup="true". Then in your code behind you type in your page eventhanders using the name "Page" followed by "_<eventname>" just like you did above with Page_PreRender. So you can also have protected void Page_Load(object sender, EventArgs e), protected void Page_Init(object sender, EventArgs e), etc. The runtime will register the eventhandler with the event for you as long as you follow the naming convention.

2. You wire them up yourself and you can use any name you want, but by convention you should still use the naming pattern. So in the constructor for your page, you can enter:
Page.Load += Page_Load, Page.PreRender += SomeOtherEventHandlerIfYouWant. In this case, set AutoEventWireup="false" otherwise you will will register it twice and it will fire twice.

There are other ways but they get more obscure.
0

Featured Post

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question