I am looking at two examples in the msdn docs.
The first example I am looking is here : http://msdn.microsoft.com/en-us/library/aa719907(VS.71).aspx
it states that by adding the event to the events property of the control it is more efficient. Also in the example they are implementing IPostBackEventHandler.
In this second example found here, http://msdn.microsoft.com/en-us/library/3257x3ea.aspx
They are are kind of doing basically the same thing but no implementation of IPostBackEventHandler.
I have a compsite control that may have up to 3 Image buttons at the same time so I am not sure if I need to create 3 private static readonly object EventSubmitKey = new object(); or just one?
I am also not sure if the IPostBackEventHandler should be implemented or not as the second example doesn't implement it, so I am assuming the CompsiteControl already does?
In this second example the buttons click event is handled in the composite control then the submit event is raised. Is it possible to handle a buttons click event in the composite control first than bubble it back to the Page or is that what this is doing?
I originally posted this question here: http://forums.asp.net/t/1405321.aspx
I have since discovered that ImageButtons implement the IPostBackEventHandler interface themselves thus causing the issue of the RaisePostBackEvent not firing. I then decided to just add an image to my composite control and was able to get the RaisePostBackEvent to fire but not until after the CreateChildControls method already fired.
Below is a code snipped of what I tried that was able to get the RaisePostBackEvent to fire but like I stated this did not fire untill after the CreateChildControls method executed. I am starting to think that is how it is suppose to work but I am not sure.
The reason I wanted the event to fire before the CreateChildControls method is so I can dynamically change what controls are in my Composite Control.
Literal myLiteral = new Literal();
myLiteral.Text = "<img src=\"Images/next.gif\" onclick=\"" +
Page.ClientScript.GetPostBackEventReference(this, "") + "\" />";