title: How to open a modal from code behind?
body: <p>I am trying to open a modal on a button click. Modal can be opened using a button click</p>
  
  <pre><code> &lt;asp:Button ID="Button4" runat="server" class="btn btn-info" data-toggle="modal" OnClientClick="return false;" data-target="#View1" Text="View Details" /&gt;
  </code></pre>
  
  <p>I need to open this modal at the end of a function, but I don't know how to make that happen, from c# code behind. I tried:</p>
  
  <pre><code> protected void Button2_Click(object sender, EventArgs e)
   {
      ScriptManager.RegisterStartupScript(this, this.GetType(), "ModalView", "&lt;script&gt;$('#View1').modal('show');&lt;/script&gt;", false);
   }
  </code></pre>
  
  <p><strong>Design</strong></p>
  
  <pre><code> &lt;!-- modal 1 --&gt;
  &lt;div class="modal fade" id="View1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" runat="server"&gt;
      &lt;div class="modal-dialog"&gt;
          &lt;div class="modal-content"&gt;
              &lt;div class="alert alert-success"&gt;
  
                  &lt;strong&gt;Well done!&lt;/strong&gt; Successfully Saved     
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;!-- modal-content --&gt;
      &lt;/div&gt;
      &lt;!-- modal-dialog --&gt;
  &lt;/div&gt;
  &lt;!-- modal --&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/mbeCG.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mbeCG.jpg" alt="enter image description here"></a></p>