Event Delegates - Raising event fails on web control.
Posted on 2008-10-28
I thought this should be a simple, clean way of accomplishing a simple requirement to display multiple menus using a single web form:
1. Create an ASP.NET web app.
2. Make a placeholder in an update panel on the default.aspx page.
3. Add to the project two web controls. Place a couple buttons on each.
4. In each web control's code behind, create a delegate - event pattern for communicating information back to the default.aspx code behind.
5. In the default.aspx code behind, wire-up a local method as the handler for each web control's event.
6. When the default.aspx fires it's page init, you load up the first web control into the placeholder.
7. User clicks a button in the loaded (and rendered) first web control that supposedly fires an event (subscribed to in default.aspx) wherein it defines a second web control to put in the placemarker.
It works right up till the point where I click on a "main menu" button in the first control. When the button click event fires, I raise an event to tell default.aspx.cs to load up a different web control, only the event itself won't fire because it's null. It's probably simpler just to show me the right way than for me to drag parts of my code out.