Javascript Can';无法让Pagemethods在c#asp.net ajax中工作

Javascript Can';无法让Pagemethods在c#asp.net ajax中工作,javascript,c#,jquery,asp.net,ajax,Javascript,C#,Jquery,Asp.net,Ajax,我已经试了一段时间了。我有一个jquery数据表,我在表上设置了onclick方法。我知道点击是有效的,因为我有一个警报集,可以给我行中的一段数据。我的下一步是从第0列获取一段数据'Quote_Num'作为整数。并将其设置为会话变量(使用pagemethods),然后调用Quote表单查找此变量,如果存在,则使用数据库中的信息设置表单。长话短说,单击quote表中的行,将获得一个包含quotes数据的页面 单击Quote表中的一行时,我被重定向到Quote.aspx,但未设置会话变量。因此,程序

我已经试了一段时间了。我有一个jquery数据表,我在表上设置了onclick方法。我知道点击是有效的,因为我有一个警报集,可以给我行中的一段数据。我的下一步是从第0列获取一段数据'Quote_Num'作为整数。并将其设置为会话变量(使用pagemethods),然后调用Quote表单查找此变量,如果存在,则使用数据库中的信息设置表单。长话短说,单击quote表中的行,将获得一个包含quotes数据的页面

单击Quote表中的一行时,我被重定向到Quote.aspx,但未设置会话变量。因此,程序使用OnSuccessCallBack方法,但从不执行c#方法中的代码。我在c#方法中设置了一个断点,但从未到达。ajax响应似乎是一个完整的网页。我还有一个脚本管理器,在母版页中将pagemethods设置为true

aspx

cs


您需要在web方法中启用会话。像这样的

//cs head
using System.Web.Services;

[WebMethod(EnableSession=true)]
public static void addQuot(string name)
{
    //this is how to access Session object in a static method
    HttpContext.Current.Session["name"] = name;
}

您需要在web方法中启用会话。像这样的

//cs head
using System.Web.Services;

[WebMethod(EnableSession=true)]
public static void addQuot(string name)
{
    //this is how to access Session object in a static method
    HttpContext.Current.Session["name"] = name;
}

谢谢你的意见。进行了建议的更改,但仍不起作用。我在addQuote()方法中设置了一个断点,但该方法从未到达。只打开quoteFrm.aspx,不带会话变量。检查控制台。有什么错误吗?同时检查请求和响应。没有控制台错误,响应似乎是一个网页,我使用了chrome开发者工具网络部分,它显示了addQuote,我选择了它,然后检查了响应,以便将测试目的更改为
void
string
返回HttpContext.Current.Session[“Quote”]。将
window.location…
更改为
console.log(数据)
。将参数
data
添加到successcallback(data){…}
函数中。检查请求(POST)。它应该是
{“Quote_Num”:1}
。确保
var quote=qTable.row(this.data()[0]
int
。好的,我将void改为string并添加了return httpCon。。。。。。。。。。。。。。。作为字符串(不喜欢对象到字符串)。更改文件。位置。。。。。。。。到console.log(数据)。这给了我一堆html到控制台。不知道如何检查请求(POST),也不知道如何验证var quote是否为int,但这是列包含的内容(数据库中的整数标识字段),谢谢您的输入。进行了建议的更改,但仍不起作用。我在addQuote()方法中设置了一个断点,但该方法从未到达。只打开quoteFrm.aspx,不带会话变量。检查控制台。有什么错误吗?同时检查请求和响应。没有控制台错误,响应似乎是一个网页,我使用了chrome开发者工具网络部分,它显示了addQuote,我选择了它,然后检查了响应,以便将测试目的更改为
void
string
返回HttpContext.Current.Session[“Quote”]。将
window.location…
更改为
console.log(数据)
。将参数
data
添加到successcallback(data){…}
函数中。检查请求(POST)。它应该是
{“Quote_Num”:1}
。确保
var quote=qTable.row(this.data()[0]
int
。好的,我将void改为string并添加了return httpCon。。。。。。。。。。。。。。。作为字符串(不喜欢对象到字符串)。更改文件。位置。。。。。。。。到console.log(数据)。这给了我一堆html到控制台。不知道如何检查请求(POST),也不确定如何验证var quote是否为int,除非该列包含int(数据库中的整数标识字段)
//cs head
using System.Web.Services;

[WebMethod(EnableSession=true)]
public static void addQuot(string name)
{
    //this is how to access Session object in a static method
    HttpContext.Current.Session["name"] = name;
}