jQuery SQL .NET-尝试创建一个可以从服务器中删除ID的删除按钮 [英] jquery sql .NET - trying to create a delete button that can remove ID's from server

查看:71
本文介绍了jQuery SQL .NET-尝试创建一个可以从服务器中删除ID的删除按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我有一个程序可以使用jquery和.NET在数据库中生成ID.我正在尝试创建一个删除按钮,以便当用户进入本节时,他们要做的就是选择ID所在的放射状按钮,然后单击删除按钮将其删除,但是我不确定该怎么做.这.我已经读过,使用某种Ajax调用可以工作,但对它的功能不熟悉.这是我到目前为止的内容:

    function UserSelection(Type_ID) {
        var Type_Value = "";

        if (Type_ID == 1)
            Type_Value = "html";
        else if (Type_ID == 2)
            Type_Value = "doc"
        else if (Type_ID == 3)
            Type_Value = "src"

        $('#userselectionmade').dialog({
            width: 700,
            height: 400,
            title: 'Generate Document',
            buttons: {
                'Edit Document': function () {
                    var documentID = $('#<%= rblUserDocument.ClientID %>').children().children().children().find("input:checked").val(); 
                    window.location = "AddEditDocument.aspx?action=Edit&documentID=" + documentID + "";
                },
                'Delete Document': function (){
                    var documentID = $('#<%= rblUserDocument.ClientID %>').children().children().children().find("input:checked").val();
                    window.location = "AddEditDocument.aspx?action=Edit&documentID=" + documentID + "";

                },
                'Cancel': function () {
                    $(this).dialog("close");
                }
            }
        })

        return false;
    }

删除文档"按钮是我遇到的问题.如果有人能指出我正确的方向,那就太好了.

解决方案

尝试下面的代码,您可以在其中将单选按钮ID保存在某个变量中,以后再使用此单选按钮ID查找最接近的行(tr)并将其删除.

'Delete Document': function (){

    var rb = $('#<%= rblUserDocument.ClientID %>').children().children().children().find("input:checked");

    var documentID = $(rb).val();
    var rbID = $(rb).attr('id');

    $.ajax({
      url: "AddEditDocument.aspx",
      type: "get",
      data: {action: "Delete", documentID: documentID},
      success: function(){
         alert("Document ID# " + documentID + " has been deleted.");

//remove whole tr        
 $('#'+rbID ).closest('tr').remove();

      },
      error:function(){
        alert("failure");
      }
   });
},

So I have a program that generates ID's within a database using jquery and .NET. I am trying to create a delete button so that when the user gets to this section, all they have to do is select the radial button in which the ID is and click the delete button to remove it, but I am unsure of how to do this. I have read that using some sort of ajax call would work but am unfamiliar with the functionality of it. Here is what I have so far:

    function UserSelection(Type_ID) {
        var Type_Value = "";

        if (Type_ID == 1)
            Type_Value = "html";
        else if (Type_ID == 2)
            Type_Value = "doc"
        else if (Type_ID == 3)
            Type_Value = "src"

        $('#userselectionmade').dialog({
            width: 700,
            height: 400,
            title: 'Generate Document',
            buttons: {
                'Edit Document': function () {
                    var documentID = $('#<%= rblUserDocument.ClientID %>').children().children().children().find("input:checked").val(); 
                    window.location = "AddEditDocument.aspx?action=Edit&documentID=" + documentID + "";
                },
                'Delete Document': function (){
                    var documentID = $('#<%= rblUserDocument.ClientID %>').children().children().children().find("input:checked").val();
                    window.location = "AddEditDocument.aspx?action=Edit&documentID=" + documentID + "";

                },
                'Cancel': function () {
                    $(this).dialog("close");
                }
            }
        })

        return false;
    }

The 'Delete Document' button is the one I am having trouble with. If anyone can point me in the right direction, that would be great.

解决方案

try the code below where you can save radiobutton id in some variable and later use this radio button ID to find closest row(tr) and remove it.

'Delete Document': function (){

    var rb = $('#<%= rblUserDocument.ClientID %>').children().children().children().find("input:checked");

    var documentID = $(rb).val();
    var rbID = $(rb).attr('id');

    $.ajax({
      url: "AddEditDocument.aspx",
      type: "get",
      data: {action: "Delete", documentID: documentID},
      success: function(){
         alert("Document ID# " + documentID + " has been deleted.");

//remove whole tr        
 $('#'+rbID ).closest('tr').remove();

      },
      error:function(){
        alert("failure");
      }
   });
},

这篇关于jQuery SQL .NET-尝试创建一个可以从服务器中删除ID的删除按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆