title: Display Bootstrap Modal from Asp.Net Webforms
body: <p>Need Suggestions, how to open a twitter bootstrap modal, from Asp.net Webform code behind?</p>
  
  <p>I want to open the modal based on some requirement at the moment of the save. Once user click on the save button , it runs the validations in code behind and if there are any validation errors , display all errors in bootstrap modal dialog. This all should happen on Save button click.</p>
  
  <p>I tried with below piece of code , but it prompts me java script error "Error: Object doesn't support property or method 'modal'". Thanks</p>
  
  <p>Asp.Net Webforms 4.5</p>
  
  <p>Bootstrap V3.0.1</p>
  
  <p>JQuery-1.9.0.js</p>
  
  <p>jquery-ui-1.8.24.js</p>
  
  <pre><code>Default.aspx 
  
  &lt;asp:Content runat="server" ID="DisplayContent" ContentPlaceHolderID="DisplayContent"&gt;
  &lt;div class="container"&gt;
  &lt;/div&gt;
  &lt;/asp:Content&gt;
  
  &lt;asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent"&gt;
  
  &lt;div class="container"&gt;
      &lt;div class="btn-group"&gt;
          &lt;asp:Button ID="btnSubmit" class="btn-info" runat="server" Text="Submit"          
          OnClick="btnSubmit_Click"&gt;&lt;/asp:Button&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  
  &lt;%--Bootstrap Modal Dialog--%&gt;
  &lt;div class="modal fade" id="myModal" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"&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" aria-hidden="true"&gt;&amp;times;&lt;/button&gt;
                  &lt;h4 class="modal-title"&gt;Validation Errors List for HP7 Citation&lt;/h4&gt;
              &lt;/div&gt;
              &lt;div class="modal-body"&gt;
              &lt;/div&gt;
              &lt;div class="modal-footer"&gt;
                  &lt;button class="btn btn-info" data-dismiss="modal" aria-hidden="true"&gt;Close&lt;/button&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;/asp:Content&gt;
  
  
  Default.aspx.cs
  
  protected void btnSubmit_Click(object sender, EventArgs e)
  {
    ScriptManager.RegisterClientScriptBlock(this, this.GetType(),"none", "
   &lt;script&gt;$('#mymodal').modal('show');&lt;/script&gt;", false);
   }
  
  
  
   Script order defined in master page
  
   &lt;asp:PlaceHolder ID="PlaceHolder1" runat="server"&gt;
      &lt;%: Scripts.Render("~/bundles/modernizr") %&gt;
      &lt;%: Scripts.Render("~/bundles/jquery") %&gt;
      &lt;%: Scripts.Render("~/bundles/bootstrap") %&gt;
      &lt;%: Scripts.Render("~/bundles/common") %&gt;
  &lt;/asp:PlaceHolder&gt;
  </code></pre>