Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/256.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 处理jquery变量,剪切部分,然后放入codebehind,如何处理?_C#_Jquery_Asp.net - Fatal编程技术网

C# 处理jquery变量,剪切部分,然后放入codebehind,如何处理?

C# 处理jquery变量,剪切部分,然后放入codebehind,如何处理?,c#,jquery,asp.net,C#,Jquery,Asp.net,})) c背后的代码# 是否可以从?id=2中提取“2”号,然后将其放入cmd.Parameters.AddWithValue(“@category\u id”,p)中您的浏览器可以通过表单提交或通过JavaScript发出POST请求向服务器发送数据 jQuery有一个post()方法,对您来说可能是这样的: using (SqlConnection conn = new SqlConnection(ConfigurationManager.Connection

}))

c背后的代码#


是否可以从
?id=2
中提取“2”号,然后将其放入
cmd.Parameters.AddWithValue(“@category\u id”,p)中

您的浏览器可以通过表单提交或通过JavaScript发出POST请求向服务器发送数据

jQuery有一个post()方法,对您来说可能是这样的:

                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString()))
            {
                SqlCommand cmd = new SqlCommand();

                cmd.Connection = conn;
                cmd.CommandText = @"UPDATE [categories] SET [category_name] = @category_name WHERE [category_id] = @category_id";
                cmd.Parameters.AddWithValue("@category_name", val);
                cmd.Parameters.AddWithValue("@category_id", p);
                conn.Open();
                cmd.ExecuteNonQuery();
                conn.Close();
            }
            Response.Redirect("panel.aspx");
        }

$(document).ready(function () {
$(function () {

    var newHash = "",

        $el;


    $(".insertPost").delegate(".category", "click", function () {

        window.location.hash = $(this).attr("href");

        return false;
    });

    $(window).bind('hashchange', function () {

        newHash = window.location.hash.substring(1);



    });

    $(window).trigger('hashchange');
    $(".category").click(function () {
        var p = window.location.hash.replace('#', '');
        alert(p)
    });
});
                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString()))
            {
                SqlCommand cmd = new SqlCommand();

                cmd.Connection = conn;
                cmd.CommandText = @"UPDATE [categories] SET [category_name] = @category_name WHERE [category_id] = @category_id";
                cmd.Parameters.AddWithValue("@category_name", val);
                cmd.Parameters.AddWithValue("@category_id", p);
                conn.Open();
                cmd.ExecuteNonQuery();
                conn.Close();
            }
            Response.Redirect("panel.aspx");
        }
$.post( "ajax/test.html", function( data ) {
  $( ".result" ).html( data );
});