title: Open modal on gridview row click
body: <p>I have a user control that has a <code>GridView</code> and when a user clicks on a row in this <code>GridView</code> the function <code>OnSelectedIndexChanged</code> is called, I'd like a modal to pop up after this occurs. I used the <code>ScriptManager</code> to invoke the script <code>$('#seasonInfoModal').modal()</code> which works in opening modals. The problem is it doesn't work when opening a modal which is defined within the same user control. The modal opens when it is inside the <code>page.aspx</code> , but doesn't open when inside the control <code>.ascx</code>. I have everything hooked up properly and have omitted some details. Here's what the overall code looks like</p>
  
  <h1>main page.aspx</h1>
  
  <pre><code>&lt;%@ Page Title="" Language="C#" ... %&gt;
  &lt;%@ Register Src="~/Controls/MyControl.ascx" TagPrefix="ACT" TagName="GeneralADM" %&gt;
  
  &lt;ACT:GeneralADM runat="server"" /&gt;
  </code></pre>
  
  <h1>MyControl.ascx</h1>
  
  <pre><code>&lt;%@ Language="C#" AutoWireUP="true" Codebehind="" Inherits="" %&gt;
  
  &lt;div runat="server"&gt;
  
       &lt;!-- Seasonal Info--&gt;
       &lt;div runat="server" id="seasonInfoModal" class="modal fade" role="dialog" draggable="true"&gt;
       &lt;/div&gt;
       &lt;!-- End seasonal info--&gt;
  
       &lt;!-- Start of Season Edit Modal --&gt;
       &lt;div id="seasonEditInfo" class="modal fade" role="dialog" draggable="false"&gt;
       &lt;/div&gt;
       &lt;!-- End of Season Edit Modal --&gt;
  
        &lt;asp:GridView&gt;
        &lt;/asp:GridView&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>In the code behind I try to open the modal like this</p>
  
  <h1>MyControl.ascx.cs</h1>
  
  <pre><code>protected void OnSelectedIndexChanged(object sender, GridViewEventArgs e){
      ScriptManager.RegisterStartupScript(this, 
        this.GetType(), 
        "seasonInfoModal", 
        "$('#seasonInfoModal').modal();", 
        true);
  }
  </code></pre>
  
  <h1>issue</h1>
  
  <p><code>#seasonInfoModal</code> doesn't popup instead a new modal is made with nothing inside it and the screen fades to dark on click. When I pull the <code>#seasonInfoModal</code> out of the control into the page where I am inserting the control itself, the modal actually pops up. </p>
  
  <h1>question</h1>
  
  <p>How can I open the modal <code>#seasonInfoModal</code> when it is inside the control from that control's codebehind specifically from inside <code>OnSelectedIndexChanged</code> function?</p>