title: RegisterStartUpScript does not fire javascript function
body: <p>I am calling a JS function from Codebehind, the function is supposed to <code>toggle()</code> or <code>show()</code> a <code>tr</code> in the <code>dom</code>. I am using the following for this purpose:</p>
  
  <pre><code>ScriptManager.RegisterStartupScript(this.Page, this.GetType(), DateTime.Now.ToString(), "ToggleTr(1)", true); 
  </code></pre>
  
  <p>If I am in a debugging mode, this works fine magically, but seems to work very spontaneously otherwise. Hence, I used a <code>timeout 500</code> for this, but I believe that is not a good approach in itself. So my other try was:</p>
  
  <pre><code>ScriptManager.RegisterStartupScript(this.Page, this.GetType(), DateTime.Now.ToString(), "window.onload = function() {ToggleTr(1);}", true);
  </code></pre>
  
  <p>But this does not help either. NOTE: I am using webform <code>aspx</code> pages templated under a <code>MasterPage</code>, So I cannot use the <code>head</code> or a <code>form</code> tag either. This is what I have in my <code>aspx</code> page:</p>
  
  <pre><code>&lt;asp:Panel ID="pnlEmployeeDetails" runat="server"&gt;
          &lt;script language="javascript" type="text/javascript"&gt;
  function ToggleTr(showFlag) {
                  if (showFlag == 1) {
                      $("#trSupervisor").show();
                  }
                  else if (showFlag == 0) {
                      $("#trSupervisor").hide();
                  }
              }
  &lt;/script&gt;
  </code></pre>
  
  <p>Secondly, I am not calling this on <code>PageLoad</code>, the calls vary on several event handlers executed.. What should I do here??</p>