client side and then server side delete

后端 未结 2 1099
误落风尘
误落风尘 2020-12-22 11:56

I have the following code:



        
相关标签:
2条回答
  • 2020-12-22 12:41

    Open your code behind and add

    public void btnDelete_Click(object sender, EventArgs e)
    {
        //Your logic here
    }
    
    0 讨论(0)
  • 2020-12-22 12:48

    You can use bootstrap's modal.

    <asp:Button ID="btnDelete" runat="server" Text="Delete" OnClick="showDialog_Event" />
    

    Page:

    <div class="container">
        <div id="modalDialog" class="modal" role="dialog">
           <div class="modal-dialog modal-sm" data-backdrop="static">
               <div class="modal-content">
                    <div class="modal-header">
                         <div class="modal-title text-center">
                               <h4>Message</h4>
                          </div>
                    </div>
                    <div id="modalBodyDialog" class="modal-body">
                    </div>
                    <div class="modal-footer">
                      <asp:Button runat="server" ID="btnOkDialog" CssClass="btn btn-default" Text="Ok" OnClick="btnOkDialog_Click" />
                      <input type="button" value="Cancel" data-dismiss="modal" />
                     </div>
                </div>
           </div>
       </div>
    

    Code:

    public void showDialog_Event(object sender, EventArgs e) {
      System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append(@"<script type='text/javascript'>");
            sb.Append("$('#modalDialog').modal({'backdrop': 'static', 'keyboard': 'static', 'show': true});");
            sb.Append("$('#modalBodyDialog').html('<ul><li>");
            sb.Append(message);
            sb.Append("</li></ul>')");
            sb.Append(@"</script>");
            Page.ClientScript.RegisterStartupScript(this.GetType(), "ModalScript", sb.ToString(), false);
    }
    

    Get event confirm (btn OK)

    public void btnOkDialog(object sender, EventArgs e) {
    // your code for delete
    }
    

    This example need bootstrap and jquery.

    0 讨论(0)
提交回复
热议问题