2016-03-02 42 views
0

運行模式我有一個模式,我想從我的語氣背後的代碼運行:如何從代碼

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>  
<asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
    <ContentTemplate> 
    <div dir="rtl" id="mymodal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalRapidAddLabel" aria-hidden="true"> 
     <div class="modal-header"> 
      <button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="float: left">×</button> 
      <h3 id="myModalRapidAddLabel">Edit Brand</h3> 
     </div> 
     <div class="modal-body"> 
      <p>Enter New Name</p> 
      <div class="control-group"> 

       <div class="controls"> 
        <asp:TextBox ID="txtnewname" runat="server"></asp:TextBox> 

       </div> 

      </div> 
     </div> 
     <div class="modal-footer"> 
      <button class="btn" data-dismiss="modal" aria-hidden="true">cancel</button> 

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

而且我的代碼背後:

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

每一個地方我shearched此代碼必須運行模式,但這不適合我爲什麼?

+0

查看您是否在客戶端得到任何錯誤?你的javascript代碼exerutes – Adil

+0

任何錯誤,但當我代碼後面運行任何事情doesent happend – sadeq

+0

是因爲你的模態是在更新面板? – ninja

回答

0

試試這個,創建一個asp button

<asp:UpdatePanel runat="server"> 
         <ContentTemplate> 
          <asp:Button runat="server" CssClass="btn btn-info" Text="Search" ID="cmdSearch" OnClick="cmdSearch_Click" /> 
         </ContentTemplate> 
        </asp:UpdatePanel> 

在後面的代碼:

 protected void cmdSearch_Click(object sender, EventArgs e) 
    { 
      ScriptManager.RegisterStartupScript(this, this.GetType(), "", 
       "$('#mymodal').modal('show');", true); 
    } 
+0

謝謝它的工作 – sadeq