title: Cannot get the ModalPopupExtender to run via code
body: <p>I cannnot get the ModalPopupExtender to work via code.  If I set the ModalPopupExtender's property TargetControlID="btn", it works.  When I set TargetControlID="HiddenField1" to use the mpe.show() method in the code, it does not work (the dgvResults_RowCommand event fires fine, I have tested it).  I have gone through many sites looking at code, and cannot figure out whats wrong. Thanks in advance for any help</p>
  
  <pre><code>&lt;%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
      CodeBehind="Default.aspx.cs" Inherits="Michlala._Default" %&gt;
  
  &lt;%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %&gt;
  
  &lt;asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"&gt;
      &lt;style type="text/css"&gt;
          .modalPopup 
          {               
              background-color: Black;
              filter: alpha(opacity=80);
              opacity: 0.8;
              z-index: 10000;             
          }
          .style1
          {
              width: 100%;
          }
          .style5
          {
              text-align: center;
          }
      &lt;/style&gt;
  &lt;/asp:Content&gt;
  &lt;asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"&gt;
      &lt;h1&gt; Student Feedback&lt;/h1&gt;
          &lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt;
          &lt;/asp:ScriptManager&gt;       
      &lt;br /&gt;
      &lt;asp:TextBox ID="txtSID" runat="server" Width="61px" Height="25px"&gt;&lt;/asp:TextBox&gt;  
      &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  
      &lt;asp:Button ID="btnSID" runat="server" onclick="Button1_Click" 
          Text="Submit Student ID" /&gt;
  
      &lt;asp:GridView ID="dgvResults" runat="server" Visible="False" 
          onrowcommand="dgvResults_RowCommand"&gt;
          &lt;Columns&gt;
              &lt;asp:TemplateField&gt;
                  &lt;EditItemTemplate&gt;
                      &lt;asp:TextBox ID="TextBox1" runat="server"&gt;&lt;/asp:TextBox&gt;                        
                  &lt;/EditItemTemplate&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:Button ID="btnFeedback" runat="server" onclick="Button1_Click1" 
                          Text="Add FeedBack" CommandName="InsertFeedback" CommandArgument="&lt;%# ((GridViewRow) Container).RowIndex %&gt;"  /&gt;
                         &lt;asp:HiddenField ID="HiddenField1" runat="server" /&gt;
                      &lt;asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" 
                           TargetControlID="HiddenField1"
                           PopupControlID="pnlModalPanel"
                           CancelControlID="btnCancel"
                           BackgroundCssClass="modalPopup" &gt; 
                      &lt;/asp:ModalPopupExtender&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:TemplateField&gt;
          &lt;/Columns&gt;
      &lt;/asp:GridView&gt;
      &lt;asp:Panel ID="pnlModalPanel" runat="server"  style="display:none" Width="481px" &gt;
          &lt;table class="style1"&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      Course
                  &lt;/td&gt;
                  &lt;td&gt;
                      Semester
                  &lt;/td&gt;
                  &lt;td class="style5"&gt;
                      Teacher Assitant
                  &lt;/td&gt;
                  &lt;td class="style5"&gt;
                      Lecturer
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      &amp;nbsp
                      &lt;asp:TextBox ID="txtCourse" runat="server"&gt;&lt;/asp:TextBox&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &amp;nbsp
                  &lt;/td&gt;
                  &lt;td&gt;
                      &amp;nbsp
                  &lt;/td&gt;
                  &lt;td&gt;
                      &amp;nbsp
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td colspan="2" style="text-align: center"&gt;
                      &lt;asp:Button ID="btnSubmit" runat="server" Text="Submit" /&gt;
                      &amp;nbsp;
                  &lt;/td&gt;
                  &lt;td colspan="2"&gt;
                      &amp;nbsp
                      &lt;asp:Button ID="btnCancel" runat="server" Text="Cancel" /&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;    
      &lt;/asp:Panel&gt;
      &lt;asp:DropDownList ID="ddlSemester" runat="server"&gt;
      &lt;/asp:DropDownList&gt;
      &lt;asp:Label ID="lblRes" runat="server" Text="Label"&gt;&lt;/asp:Label&gt;        
      &lt;br /&gt;        
  &lt;/asp:Content&gt;
  </code></pre>
  
  <p>in the server side code </p>
  
  <pre><code>protected void dgvResults_RowCommand(object sender, GridViewCommandEventArgs e)
  {
      ModalPopupExtender mpe = new ModalPopupExtender();
      mpe.Show();
  }
  </code></pre>