title: Prevent bootstrap modal closing on postback in ASP.NET
body: <p>I have a bootstrap modal I want to show in order to perform a search and select funcionality in a ASP.NET Web form. The problem is when the user clicks on "Search" button, the modal closes. I want the modal keeps open to show search results on GridView below and closes when the user selects any GridView item. </p>
  
  <p>I've tried other solutions mentioned in other threads but nothing seems to work. I'm using a WebForm with a Master page, I don't know if it can be causin me the issue.</p>
  
  <p>This is my modal code:</p>
  
  <pre><code>&lt;div class="modal fade" id="modSearchByAccount" role="dialog"&gt;
  &lt;div class="modal-dialog"&gt;
      &lt;div class="modal-content"&gt;
          &lt;div class="modal-header"&gt;
              &lt;button type="button" class="close" data-dismiss="modal"&gt;&amp;times;&lt;/button&gt;
              &lt;h4 class="modal-title"&gt;Search by Account&lt;/h4&gt;
          &lt;/div&gt;
          &lt;div class="modal-body"&gt;
              &lt;div class="row"&gt;
                  &lt;div class="col-md-8"&gt;
                      &lt;asp:TextBox ID="txtSearchText" runat="server" CssClass="form-control" placeholder="Account name"&gt;&lt;/asp:TextBox&gt;
                  &lt;/div&gt;
                  &lt;div class="col-md-4"&gt;
                       &lt;asp:Button ID="btnSearchAccount" runat="server" OnClick="btnSearchAccount_Click" Text="Buscar" CssClass="btn btn-default" /&gt;
                  &lt;/div&gt;    
              &lt;/div&gt;
              &lt;div class="row"&gt;
                  &lt;div class="col-md-12"&gt;
                       &lt;asp:Panel ID="pnlSearchResults" runat="server" ScrollBars="Vertical" Height="200px" Width="100%"&gt;
                          &lt;asp:GridView ID="gvSearchResults" runat="server" AutoGenerateColumns="False" DataKeyNames="ACCOUNT_ID" OnSelectedIndexChanged="gvSearchResults_SelectedIndexChanged" CssClass="table table-striped table-hover"&gt;
                              &lt;Columns&gt;
                                  &lt;asp:BoundField DataField="ACCOUNT_ID" HeaderText="ID" /&gt;
                                  &lt;asp:BoundField DataField="ACCOUNT_NAME" HeaderText="Name" /&gt;
                                  &lt;asp:CommandField ShowSelectButton ="true" /&gt;
                              &lt;/Columns&gt;
                          &lt;/asp:GridView&gt;
                      &lt;/asp:Panel&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="modal-footer"&gt;
              &lt;button type="button" class="btn btn-default" data-dismiss="modal"&gt;Close&lt;/button&gt;
          &lt;/div&gt;
      &lt;/div&gt; 
   &lt;/div&gt;
  </code></pre>
  
  <p>
  </p>
  
  <p>Any ideas? Can I use an UpdatePanel somewhere here?</p>
  
  <p>Thanks in advance!</p>