mardi 5 mai 2015

How to call a function that is in the code behind of jquery dialog

I try to show jquery dialog by clicking the Delete button ( which also serves to erase data if the user than in the dialog ), but when I press the Delete dialog then disappears after the second and screen pops . I'd love someone to help me because I really green in jquery And how to check user code approved in dialog Thank you :)

    <script type="text/javascript">
            $(function () {
                $("#dialog-confirm").hide();
                $("#but_Delete").click(function () {
                    $("#dialog-confirm").dialog({
                        resizable: false,
                        height: 250,
                        width: 500,
                        modal: true,
                        buttons: {
                            "delete": function () {
                                $.ajax({
                                    type: "GET",
                                    contenttype: "application/json; charset=utf-8",
                                    data: "{null}",
                                    url: "http://ift.tt/1dMetLe",
                                    dataType: "json",
                                    success: function but_Delete_Click(res) {
                                       
                                    },
                              
                                });
                                $(this).dialog("close");
                            },
                            "Cancel": function () {
                                $(this).dialog("close");
                            }
                        }


                    });

                    //$(".selector").dialog({Zz
                    //    closeOnEscape: false

                    //});
                });

            });

  </script> 
protected void but_Delete_Click()
{          
     if (TextBox_campeny.Text != null || TextBox_Addres.Text != null || TextBox_tel.Text != null)
     {                 
           con.Open();
           string id = tb.Tables[0].Rows[i]["id"].ToString();
           SqlCommand cmd = new SqlCommand("Delete from tbl_Customer where Id='" + id + "'", con);
           cmd.ExecuteNonQuery();                 
           Response.Write("blabla!");
           con.Close();
           con.Open();
           SqlCommand cmd_u = new SqlCommand("Delete from tbl_Users where IdCustomer='" + id + "'", con);
           SqlDataAdapter dac = new SqlDataAdapter(cmd_u);
           dac.Fill(tb);
           if (butuc == 1)
           {
                 Response.Redirect("LoginPage.aspx");
           }
           else
           {
                 if(tb.Tables[0].Rows.Count != 1)
                 {
                     if (i == 0)
                     {                                
                           bind();
                     }
                     else
                     {
                           if (tb.Tables[0].Rows.Count - 1 == i)
                           {
                                  i--;
                                  bind();
                           }
                           else
                           {
                                  bind();                                  
                           }
                      }
                      else
                      {
                           Empty_Textbox();
                           but_Delete.EnableTheming = false;
                      }

                  }
             }
             con.Close();
       }
}

Aucun commentaire:

Enregistrer un commentaire