Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is an interesting way of skinning the cat. You are not asking "What did I do wrong", but "what are the likely things that I could have done wrong".</p> <p>Interesting, because I think it shows that you want to figure it our on your own, but also because I am having a hard time coming up with suggestions, without any kind of a hint. There is an almost unlimited number of possibilities.</p> <p>If the form posts back, the event fires. I think this is synonmous. If you don't see an event handler being invoked, maybe you are looking at the wrong place.</p> <p>I find this method useful in such situations. I call it from page_load, and it shows me details about what caused the event to fire, before event handlers are invoked.</p> <pre><code> /// &lt;summary&gt; /// Find which control caused the post back /// &lt;/summary&gt; /// &lt;param name="page"&gt;&lt;/param&gt; /// &lt;returns&gt;&lt;/returns&gt; public static System.Web.UI.Control GetPostBackControl(System.Web.UI.Page page) { Control control = null; string ctrlname = page.Request.Params["__EVENTTARGET"]; if (ctrlname != null &amp;&amp; ctrlname != String.Empty) { control = page.FindControl(ctrlname); } // if __EVENTTARGET is null, the control is a button type and we need to // iterate over the form collection to find it else { string ctrlStr = String.Empty; Control c = null; foreach (string ctl in page.Request.Form) { // handle ImageButton controls ... if (ctl.EndsWith(".x") || ctl.EndsWith(".y")) { ctrlStr = ctl.Substring(0, ctl.Length - 2); c = page.FindControl(ctrlStr); } else { c = page.FindControl(ctl); } if (c is System.Web.UI.WebControls.Button || c is System.Web.UI.WebControls.ImageButton) { control = c; break; } } } return control; } </code></pre>
 

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