Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I had a similar problem. In my case the button was contained in a panel and although buttons on the parent control worked correctly the button on the child Panel control didn't.</p> <p>It turns out that you need to call <code>EnsureChildControls</code> in the <code>OnLoad</code> method in the child panel to ensure that <code>CreateChildControls</code> is called early enough in the <a href="http://msdn.microsoft.com/en-us/library/ms178472.aspx" rel="nofollow noreferrer">life cycle of the page</a> so that controls can respond to events. This is described briefly in <a href="https://stackoverflow.com/questions/2073282/button-click-event-not-getting-fired-in-webparts-when-inherited-from-other-webpar/2074423#2074423">this answer here</a> which is where I discovered the solution to my problem.</p> <p>Following this instruction I just added the following code to my panel control:</p> <pre><code> protected override void OnLoad(EventArgs e) { EnsureChildControls(); base.OnLoad(e); } </code></pre> <p>I notice that there appears to be a lot of confusion about this issue in the forums so to demonstrate that this works I added trace statements to my code. Below are the results from the before and after cases. Note that the position of <code>Survey list creating child controls</code> moves from within the PreRender event to within the Load event.</p> <p>Before:</p> <p><img src="https://i.stack.imgur.com/SCK6D.png" alt="Before making the change to call EnsureChildControls in the OnLoad override"></p> <p>After:</p> <p><img src="https://i.stack.imgur.com/5aF4o.png" alt="After making the change to call EnsureChildCOntrols in the OnLoad override which shows the child controls being created in the correct place in the page life cycle"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload