FriendlyUrl 어셈블리에 추가 할 때 jQuery 드래그 앤 드롭이 작동하지 않습니다.

TDC

사용자가 한 GridView에서 다른 GridView로 행을 끌어서 활성에서 비활성으로 (또는 그 반대로) 레코드를 업데이트 할 수 있도록하는 끌어서 놓기를 만들었습니다. 내가 직면 한 문제는 Global.asax Application_Start를 통해 FriendlyUrl RouteConfig를 추가하면 레코드가 저장되지 않는다는 것입니다.

Javasccript를 포함한 내 HTML :

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="default.aspx.cs" Inherits="DragAndDrop._default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Grids</title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:GridView ID="InactiveClients" runat="server" ShowHeaderWhenEmpty="true" CssClass="drag_drop_grid gridview" HeaderStyle-CssClass="gridview-header"  AutoGenerateColumns="false">
                <Columns>
                    <asp:TemplateField HeaderText="Key" SortExpression="">
                        <ItemTemplate>
                            <asp:Label ID="ClientKey" runat="server" Text='<%# Bind("ClientKey") %>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Name" SortExpression="">
                        <ItemTemplate>
                            <asp:Label ID="ClientName" runat="server" Text='<%# Bind("ClientName") %>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Code" SortExpression="">
                        <ItemTemplate>
                            <asp:Label ID="ClientCode" runat="server" Text='<%# Bind("ClientCode") %>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="IsActive" SortExpression="">
                        <ItemTemplate>
                            <asp:CheckBox ID="IsActive" runat="server" Checked='<%# Convert.ToBoolean(Eval("IsActive")) %>'/>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
        </div>
        <div>
        
        </div>
        <div>
            <asp:GridView ID="ActiveClients" ShowHeaderWhenEmpty="true" runat="server" CssClass="drag_drop_grid gridview" HeaderStyle-CssClass="gridview-header" AutoGenerateColumns="false">
                <Columns>
                    <asp:TemplateField HeaderText="Key" SortExpression="">
                        <ItemTemplate>
                            <asp:Label ID="ClientKey" runat="server" Text='<%# Bind("ClientKey") %>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Name" SortExpression="">
                        <ItemTemplate>
                            <asp:Label ID="ClientName" runat="server" Text='<%# Bind("ClientName") %>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Code" SortExpression="">
                        <ItemTemplate>
                            <asp:Label ID="ClientCode" runat="server" Text='<%# Bind("ClientCode") %>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="IsActive" SortExpression="">
                        <ItemTemplate>
                            <asp:CheckBox ID="IsActive" runat="server" Checked='<%# Convert.ToBoolean(Eval("IsActive")) %>'/>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
        </div>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
        <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css" />
        <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/json2/20130526/json2.min.js"></script>
        <script type="text/javascript">
            $(function () {
                $(".drag_drop_grid").sortable({
                    items: 'tr:not(tr:first-child)',
                    cursor: 'arrow',
                    connectWith: '.drag_drop_grid',
                    axis: 'x,y',
                    dropOnEmpty: true,
                    start: function (e, ui) {
                        ui.item.addClass("selected");
                    },
                    receive: function (e, ui) {
                        setTimeout(function () {
                            ui.item.find('[id*=IsActive]').removeAttr('checked');
                            var obj = {};
                            obj.ClientKey = $.trim(ui.item.find('[id*=ClientKey]').html());
                            if (ui.sender[0].id == "InactiveClients") {
                                obj.IsActive = "true";
                                ui.item.find('[id*=IsActive]').attr('checked', 'checked');
                            }
                            else if (ui.sender[0].id == "ActiveClients") {
                                obj.IsActive = "false";
                                ui.item.find('[id*=IsActive]').removeAttr('checked');
                            }

                            ui.item.removeClass("selected");
                            $.ajax({
                                type: "POST",
                                url: "Default.aspx/SaveClient",
                                data: JSON.stringify({ cdata: obj }),
                                contentType: "application/json; charset=utf-8",
                                dataType: "json"
                            });
                            $(this).find("tbody").append(ui.item);
                            return false;
                        }, 100);
                    },
                });
            });
        </script>
    </form>
</body>
</html>

내 코드 뒤에 :

using System;
using System.Web.UI;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.Script.Services;
using System.Web.Services;

namespace DragAndDrop
{
    public partial class _default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {

                string conString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
                using (SqlConnection con = new SqlConnection(conString))
                {
                    using (SqlCommand cmd = new SqlCommand("SELECT ClientKey, ClientName, ClientCode, IsActive FROM TBLClientData WHERE IsActive = 0 ORDER BY ClientName", con))
                    {
                        con.Open();

                        SqlDataAdapter da = new SqlDataAdapter(cmd);
                        DataTable dt = new DataTable();
                        da.Fill(dt);
                        InactiveClients.UseAccessibleHeader = true;
                        InactiveClients.DataSource = dt;
                        InactiveClients.DataBind();
                        con.Close();
                    }

                    using (SqlCommand sqlcmd = new SqlCommand("SELECT ClientKey, ClientName, ClientCode, IsActive FROM TBLClientData WHERE IsActive = 1 ORDER BY ClientName", con))
                    {
                        con.Open();
                        SqlDataAdapter da = new SqlDataAdapter(sqlcmd);
                        DataTable dt = new DataTable();
                        da.Fill(dt);
                        ActiveClients.UseAccessibleHeader = true;
                        ActiveClients.DataSource = dt;
                        ActiveClients.DataBind();
                        con.Close();
                    }
                }
            }
        }

        public class UpdateClient
        {
            public string ClientKey { get; set; }
            public string IsActive { get; set; }
        }

        [WebMethod]
        [ScriptMethod]
        public static void SaveClient(UpdateClient cdata)
        {
            bool isact = Convert.ToBoolean(cdata.IsActive);
            string conString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
            using (SqlConnection con = new SqlConnection(conString))
            {
                using (SqlCommand cmd = new SqlCommand("UPDATE TBLClientData SET IsActive = @IsActive WHERE ClientKey = @ClientKey", con))
                {
                    //cmd.CommandType = CommandType.Text;
                    con.Open();
                    cmd.Parameters.AddWithValue("@IsActive", isact);
                    cmd.Parameters.AddWithValue("@ClientKey", cdata.ClientKey);
                    cmd.ExecuteNonQuery();
                    con.Close();
                }
            }
        }
    }
}

내 Global.asax 파일 :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.Web.Optimization;
using System.Web.Routing;

namespace DragAndDrop
{
    public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {
            RouteConfig.RegisterRoutes(RouteTable.Routes);
        }

        protected void Session_Start(object sender, EventArgs e)
        {

        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {

        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {

        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }
    }
}

내 RouteConfig.cs 파일 :

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Routing;
using Microsoft.AspNet.FriendlyUrls;

namespace DragAndDrop
{
    public static class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            var settings = new FriendlyUrlSettings();
            settings.AutoRedirectMode = RedirectMode.Permanent;
            routes.EnableFriendlyUrls(settings);
        }
    }
}

RouteConfig.RegisterRoutes(RouteTable.Routes);내 Global.asax에서 주석을 달면 레코드가 드롭 후 업데이트됩니다. RouteConfig를 포함하는 동안 JSON / SaveClient WebMethod를 통해 테이블 ​​업데이트가 작동하도록하는 방법이 있습니까?

TDC

나는 그것을 알아. settings.AutoRedirectMode = RedirectMode.Off;RouteConfig를 설정 하면 문제가 해결됩니다.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

개체가 겹칠 때 Unity 드래그 앤 드롭이 작동하지 않음

분류에서Dev

어셈블리를 실행할 때 하위 모듈 어셈블리가 빌드되지 않았습니다. 부모에서 어셈블리 : 어셈블리?

분류에서Dev

QGraphicsView 드래그 앤 드롭이 로컬 이미지를 내 앱으로 드래그 할 때 작동하지 않습니다.

분류에서Dev

Microsoft Windows에서 HTML5 드래그 앤 드롭을 사용할 때 드래그 앤 드롭으로 드래그 할 때 드래그 아이콘 (고스트 이미지)이 표시됩니다.

분류에서Dev

ScrollViewer에서 드래그 앤 드롭이 작동하지 않음

분류에서Dev

팔레트에서 드래그 앤 드롭 할 때 필드가 디자인 인터페이스에 표시되지 않는 이유는 무엇입니까?

분류에서Dev

jquery 드래그 앤 드롭 코드가 무작위 위치에서 작동하지 않는 이유는 무엇입니까?

분류에서Dev

드래그 앤 드롭 이미지 업로드가 특정 브라우저에서 작동하지 않음

분류에서Dev

드래그 앤 드롭이 작동하지 않습니까?

분류에서Dev

버전에서 업그레이드 할 때 jQuery JS가 더 이상 작동하지 않습니다.

분류에서Dev

드래그 앤 드롭으로 복사가 vscode에서 작동하지 않는 이유

분류에서Dev

드래그 앤 드롭이 EaselJS를 사용하는 크롬에서 작동하지 않습니다.

분류에서Dev

JQuery를 사용하여 이미지를 드래그 앤 드롭하고 업로드 할 수 있습니까?

분류에서Dev

Dropzone.js 드래그 앤 드롭이 IE10에서 작동하지 않습니다.

분류에서Dev

드래그 앤 드롭 옵션이 imap php의 모든 폴더에서 작동하지 않습니다.

분류에서Dev

양방향 드래그 앤 드롭이 VirtualBox 및 Ubuntu 14.04에서 작동하지 않습니다.

분류에서Dev

Ubuntu 17.10의 Nautilus에서 드래그 앤 드롭이 작동하지 않음

분류에서Dev

크롬에서 드래그 앤 드롭이 작동하지 않음

분류에서Dev

knockout.js에서 파일 드래그 앤 드롭이 작동하지 않음

분류에서Dev

QgraphicsView 내에서 드래그 앤 드롭이 작동하지 않음 (PyQt)

분류에서Dev

드래그 앤 드롭 요소 jquery에서 클릭 이벤트를 실행할 수 없습니다.

분류에서Dev

jQuery 드래그 앤 드롭 div로 다른 이미지 변경

분류에서Dev

QTreeWidgetItem의 드래그 앤 드롭이 제대로 작동하지 않습니다.

분류에서Dev

UWP-드래그 앤 드롭 중에 이벤트가 트리거되지 않고 ListView를 종료 할 때 마우스 커서를 변경할 수있는 방법이 있습니까?

분류에서Dev

Prestashop 모듈에 jquery 드래그 앤 드롭 추가

분류에서Dev

여러 드래그 앤 드롭이 작동하지 않음

분류에서Dev

주 실행 가능 어셈블리를 수동으로로드 할 때 클립 보드가 작동하지 않습니다.

분류에서Dev

jQuery 드래그 앤 드롭 항목이 자동으로 자리 표시 자로 이동합니다.

분류에서Dev

Android :보기가 이동하는 경우 드래그 앤 드롭이 작동하지 않음 (TranslateAnimation)

Related 관련 기사

  1. 1

    개체가 겹칠 때 Unity 드래그 앤 드롭이 작동하지 않음

  2. 2

    어셈블리를 실행할 때 하위 모듈 어셈블리가 빌드되지 않았습니다. 부모에서 어셈블리 : 어셈블리?

  3. 3

    QGraphicsView 드래그 앤 드롭이 로컬 이미지를 내 앱으로 드래그 할 때 작동하지 않습니다.

  4. 4

    Microsoft Windows에서 HTML5 드래그 앤 드롭을 사용할 때 드래그 앤 드롭으로 드래그 할 때 드래그 아이콘 (고스트 이미지)이 표시됩니다.

  5. 5

    ScrollViewer에서 드래그 앤 드롭이 작동하지 않음

  6. 6

    팔레트에서 드래그 앤 드롭 할 때 필드가 디자인 인터페이스에 표시되지 않는 이유는 무엇입니까?

  7. 7

    jquery 드래그 앤 드롭 코드가 무작위 위치에서 작동하지 않는 이유는 무엇입니까?

  8. 8

    드래그 앤 드롭 이미지 업로드가 특정 브라우저에서 작동하지 않음

  9. 9

    드래그 앤 드롭이 작동하지 않습니까?

  10. 10

    버전에서 업그레이드 할 때 jQuery JS가 더 이상 작동하지 않습니다.

  11. 11

    드래그 앤 드롭으로 복사가 vscode에서 작동하지 않는 이유

  12. 12

    드래그 앤 드롭이 EaselJS를 사용하는 크롬에서 작동하지 않습니다.

  13. 13

    JQuery를 사용하여 이미지를 드래그 앤 드롭하고 업로드 할 수 있습니까?

  14. 14

    Dropzone.js 드래그 앤 드롭이 IE10에서 작동하지 않습니다.

  15. 15

    드래그 앤 드롭 옵션이 imap php의 모든 폴더에서 작동하지 않습니다.

  16. 16

    양방향 드래그 앤 드롭이 VirtualBox 및 Ubuntu 14.04에서 작동하지 않습니다.

  17. 17

    Ubuntu 17.10의 Nautilus에서 드래그 앤 드롭이 작동하지 않음

  18. 18

    크롬에서 드래그 앤 드롭이 작동하지 않음

  19. 19

    knockout.js에서 파일 드래그 앤 드롭이 작동하지 않음

  20. 20

    QgraphicsView 내에서 드래그 앤 드롭이 작동하지 않음 (PyQt)

  21. 21

    드래그 앤 드롭 요소 jquery에서 클릭 이벤트를 실행할 수 없습니다.

  22. 22

    jQuery 드래그 앤 드롭 div로 다른 이미지 변경

  23. 23

    QTreeWidgetItem의 드래그 앤 드롭이 제대로 작동하지 않습니다.

  24. 24

    UWP-드래그 앤 드롭 중에 이벤트가 트리거되지 않고 ListView를 종료 할 때 마우스 커서를 변경할 수있는 방법이 있습니까?

  25. 25

    Prestashop 모듈에 jquery 드래그 앤 드롭 추가

  26. 26

    여러 드래그 앤 드롭이 작동하지 않음

  27. 27

    주 실행 가능 어셈블리를 수동으로로드 할 때 클립 보드가 작동하지 않습니다.

  28. 28

    jQuery 드래그 앤 드롭 항목이 자동으로 자리 표시 자로 이동합니다.

  29. 29

    Android :보기가 이동하는 경우 드래그 앤 드롭이 작동하지 않음 (TranslateAnimation)

뜨겁다태그

보관