2016-05-12 72 views
0

嗨,我有很多麻烦。我有一个引导模式,我试图从ASP.net中的服务器端代码(C#)打开。我看过其他文章,但我仍然在找麻烦。ScriptManager.RegisterClientScriptBlock不打开引导模式

aspx.cs页面

private void message(){ 

ModalBody.Text = "You have reached your credit limit"; 
ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(),"myModal","$('#myModal').modal('show');", true); 
      upModal.Update(); 
} 

ASPX页面

<div class="modal fade" id="myModal" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false"> 
     <div class="modal-dialog"> 
      <asp:UpdatePanel ID="upModal" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional"> 
       <ContentTemplate> 
        <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">xxxxxx</h4> 
         </div> 
         <div class="modal-body"> 
          <asp:Label ID="ModalBody" runat="server" Text=""></asp:Label> 
          <br /> 
          <br /> 
          <asp:Label ID="ModalBody2" runat="server" Text=""></asp:Label> 
         </div> 
         <div class="modal-footer"> 
          <button class="btn btn-info" data-dismiss="modal" aria-hidden="true">Close</button> 
         </div> 
        </div> 

</ContentTemplate> 
      </asp:UpdatePanel> 
     </div> 
    </div> 

我注意到,当我移动

ModalBody.Text = "You have reached your credit limit"; 
ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(),"myModal","$('#myModal').modal('show');", true); 
      upModal.Update(); 

本节进入Page_Load方法,它工作正常,并弹出与文本一起显示。我甚至跨过了一步,但它并没有做太多甚至看到了控制台。

谢谢

回答