无法从阿贾克斯在.NET C#通过岗位价值转移到页 [英] unable to pass post value over from ajax to the page in .net c#

查看:129
本文介绍了无法从阿贾克斯在.NET C#通过岗位价值转移到页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

没有人知道它是什么回事?我也试图通过值从阿贾克斯为.aspx,但不知何故价值似乎并没有越过成功。

Does anyone know what is it going on here? I have try to pass a value from ajax to .aspx, but somehow the value seem doesn't pass over successfully.

以下是我的code:

  $.ajax({
      type: "POST",
      url: "pgtest.aspx",
      data: "sState=VIC",
      success: function (msg) {
          alert("Data Saved: " + msg);
      }
  });

这是在我的.NET C#我code:

and this is my code inside my .net c#:

newTest.Value = Request.QueryString["sState"];

不知何故,为的Request.QueryString [sState]是空的。NET C#。有谁知道是怎么回事错在这里?

Somehow the for Request.QueryString["sState"] is empty in .net c#. Does anyone know what is going wrong here ?

推荐答案

当在POST传递数据,数据是不是在的Request.QueryString 过去了,它传递到的Request.Form 代替。尝试

When passing data in POST, the data is not passed in Request.QueryString, it's passed into Request.Form instead. Try

newTest.Value = Request.Form["sState"];

另一件事我会改变的是jQuery的电话 - 只使用一个字符串的数据对象,而不是一个这样的:

Another thing I'd change is the jQuery call - use a data object instead of just a string, a such:

$.ajax({
      type: "POST",
      url: "pgtest.aspx",
      data: { sState: "VIC" },
      success: function (msg) {
          alert("Data Saved: " + msg);
      }
});

这篇关于无法从阿贾克斯在.NET C#通过岗位价值转移到页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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