+ -
当前位置:首页 → 问答吧 → 大虾们,怎么在aspx中接受js传过来的数据啊。

大虾们,怎么在aspx中接受js传过来的数据啊。

时间:2011-12-02

来源:互联网

function sentToAsp(hotkey) {

  $.ajax({
  type: "get",
  url: "WebForm1.aspx",
  data: { "hotkey": hotkey.toString() },

  success: function (hotkey) {
  alert("send");
  },

  contentType: "application/json; charset=utf-8",
  dataType: "json",
  error: function () {
  alert("error");
  }

  });
}
这个是我js上的发送代码。但不知道怎么接受在aspx.cs中。
我看过有种方法好像是request();但不知道能不能用这个方法。。

作者: kingstep   发布时间: 2011-12-02

asp.net用 Request["hotkey"]
asp 用 request("hotkey")

作者: p2227   发布时间: 2011-12-02

引用 1 楼 p2227 的回复:

asp.net用 Request["hotkey"]
asp 用 request("hotkey")

额 原来这样
  public partial class WebForm1 : System.Web.UI.Page
  {
  [WebMethod]
  protected void Page_Load(object sender, EventArgs e)
  { string Key = Request["hotkey"];  
  }
  },,这样就可以收到了?

作者: kingstep   发布时间: 2011-12-02

引用 2 楼 kingstep 的回复:

引用 1 楼 p2227 的回复:

asp.net用 Request["hotkey"]
asp 用 request("hotkey")

额 原来这样
public partial class WebForm1 : System.Web.UI.Page
{
[WebMethod]
protected void Page_Load(……
你为什么不实际测试后再反馈情况呢

作者: p2227   发布时间: 2011-12-02