title: Trouble getting a reference to a ModalPopupExtender using javascript
body: <p>I am trying to use the following code to get a reference to a modalpopupextender, but when I check the value of the javascript variable 'modal' it is always null.  What is the proper way to get a reference to the AJAX control using javascript?</p>
  
  <p>.vb</p>
  
  <pre><code>        Dim myStringBuilder As New StringBuilder(246)
          myStringBuilder.AppendFormat("      &lt;script type=""text/javascript""&gt;{0}", Environment.NewLine)
          myStringBuilder.AppendFormat("            var modal = $find('&lt;%=modal1.ClientID%&gt;');{0}", Environment.NewLine)
          myStringBuilder.AppendFormat("            debugger;{0}", Environment.NewLine)
          myStringBuilder.AppendFormat("            $find('&lt;%=modal1.ClientID%&gt;').add_showing({0}", Environment.NewLine)
          myStringBuilder.AppendFormat("                function(){0}", Environment.NewLine)
          myStringBuilder.AppendFormat("                {{{0}", Environment.NewLine)
          myStringBuilder.AppendFormat("                    alert(""Modal popup will be showing"");{0}", Environment.NewLine)
          myStringBuilder.AppendFormat("                }}{0}", Environment.NewLine)
          myStringBuilder.AppendFormat("            );{0}", Environment.NewLine)
          myStringBuilder.AppendFormat("      &lt;/script&gt;{0}", Environment.NewLine)
          ClientScript.RegisterStartupScript(Me.GetType(), "myJSalert", myStringBuilder.ToString())
  </code></pre>
  
  <p>.aspx</p>
  
  <pre><code>        &lt;ajaxToolkit:ModalPopupExtender ID="mpeResetConfirm" runat="server"
          TargetControlID="btnReset" PopupControlID="pnlConfirmation" BehaviorID="modal1"/&gt; 
  </code></pre>