2017-07-24 6 views
4

ich ein HTML-modal verwenden,öffnen HTML-modale Popup von C# -Code hinter

HTML

<!-- Modal --> 
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> 
    <div class="modal-dialog"> 
     <div class="modal-content"> 
      <div class="modal-header"> 
       <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> 
       <h4 class="modal-title" id="myModalLabel">Server Message</h4> 
      </div> 
      <div class="modal-body"> 
       <div class="table-responsive"> 
        <table class="table mb30"> 
         <thead> 
          <tr> 
           <th>#</th> 
           <th></th> 
           <th></th> 
          </tr> 
         </thead> 
         <tbody> 
          <tr> 
           <td>1</td> 
           <td>Return Message</td> 
           <td><asp:Label ID="Label1" class="col-sm-8 control-label" runat="server" Text="Label"></asp:Label></td> 

          </tr> 
          <tr> 
           <td>2</td> 
           <td>Return ID</td> 
           <td><asp:Label ID="Label2" class="col-sm-8 control-label" runat="server" Text="Label"></asp:Label></td> 

          </tr> 
          <tr> 
           <td>3</td> 
           <td>Return Status</td> 
           <td><asp:Label ID="Label3" class="col-sm-8 control-label" runat="server" Text="Label"></asp:Label></td> 

          </tr> 
         </tbody> 
        </table> 
       </div> 
       <!-- content1 end --> 
      </div> 
      <div class="modal-footer"> 
       <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> 
      </div> 
     </div> 
     <!-- modal-content --> 
    </div> 
    <!-- modal-dialog --> 
</div> 
<!-- modal --> 

Ich habe versucht, dieses Modell zu öffnen von C# -Code hinter Funktion

ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "none", "<script>$('#myModal').modal('show');</script>", false); 

Aus irgendeinem Grund funktioniert es nicht.
Ich möchte dieses Modal am Ende der Speicherfunktion mit Rückgabewerten anzeigen. Dieses Modal kann auf Knopfdruck geöffnet werden, aber wie kann ich dieses Modal von C# -Funktion öffnen?

Antwort

0

Sie können so tun.

Erstellen Sie eine JavaScript-Funktion

<script> 
    function ShowPopup() 
    { 
     $('#myModal').modal('show'); 
    } 
</script> 

Jetzt unten Funktion aufrufen:

ScriptManager.RegisterStartupScript(this, this.GetType(), "none", "ShowPopup();", true);