This code is rather confusing:
1) default_click is in a place that doesn't permit the file to compile. I can only assume it is supposed to be part of the class "Default5".
2) You posted code for "blank.ascx.cs", but where is the ASCX file?
3) You needn't register the same user control file (blank.ascx) twice. You can reuse a single control in the page.
4) You have declared a delegate and event in both the "header" class and the "blank" class. This greatly confused the issue but I think I see why it is in there twice. I would guess that you added in the same delegate and event in blank in the hopes it would result in the automatic bubbling of the event. Unfortunately, it doesn't work that way.
In this line:
Code:
header_area.Controls.Add(LoadControl(@"~/user_controls/header.ascx"));
you are creating a new instance of "header" which has the link buttons. You add this to the "header_area" div control. But then you wire the button click handler to the clicked events of your blank placeholder control instances (header, menu) instead of the actual header control. There is nothing in the "blank" class that ever calls those events.
A fix is to save off the instance of the header control you load so that you can wire up to its events:
Code:
header myHeader;
myHeader = (header)LoadControl(@"~/user_controls/header.ascx");
header_area.Controls.Add(myHeader);
if(Page.IsPostBack)
{
myHeader.clicked += new header.OnButtonClick(default_click);
}
Incidentally, the <asp:panel> renders as a DIV tag. Alternatively, if all you really need is a control placeholder, try the <asp:placeholder> control which renders no HTML.
-Peter
compiledthoughts.com