English 中文(简体)
页: 1
原标题:unable to pass post value over from ajax to the page in .net c#

是否有任何人知道这种情况发生? 我试图将价值从ja到asp,但在某种程度上,价值似乎并未成功通过。

我的法典如下:

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

这是我在我方言中制定的法典:

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

有些是请求。 QueryString[“sState”]在net c#中是空洞的。 是否有任何人知道这里有什么错误?

最佳回答

在通过POST数据时,数据不通过<代码>查询。 QueryString, 它通过成为Request。 表格。 提 出

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

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);
      }
});
问题回答

<代码>查询。 缩略语/代码只适用于GET申请。 如欲查阅,请查阅<编码>。 表格。 另见:。 查阅C#/ASP.NET的POST数据

你们需要使用全球培训要求,因为这一请求在性质上是轻而易举的,而且在提出疑问时也得到采纳。

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

现在,你们的价值观如下:

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




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...