joepeacock
Programmer
I'm having a strange problem with form fields not being available to my .aspx.cs pages after being POSTed from another page. In order to rule out any interference from other features, I created two simple pages "test.aspx" and "test2.aspx" -- test posts a form to test2.
=== test.aspx ===========
<%@ Page Title="TEST" CodeFile="test.aspx.cs" Language="C#" AutoEventWireup="true" Inherits="test" Codebehind="test.aspx.cs" %>
<html>
<body>
<form method="post" action="/test2.aspx">
<input type="text" name="testField" /><input type="submit" value="Go" />
</form>
</body>
</html>
=========================
=== test2.aspx.cs =======
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class test2: System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
foreach (string param in Request.Form)
{
Response.Write(param + "=" + Request.Form[param] + "<br />");
}
}
}
=========================
(test2.aspx is empty except the default stuff Visual Studio adds when creating a new web form)
When I build this and load it in my browser, there is nothing output on test2.aspx. HOWEVER, if I debug it, using F5 in Visual Studio, then it works as expected.
I have tried removing the "Form" and just looking for the POSTed value in Request.Params. When I do that, I see all of the request values, cookies, etc, but still not the form field value (again, it does show up, as expected, when debugging).
What am I doing wrong, here? Please help!
Thanks
=== test.aspx ===========
<%@ Page Title="TEST" CodeFile="test.aspx.cs" Language="C#" AutoEventWireup="true" Inherits="test" Codebehind="test.aspx.cs" %>
<html>
<body>
<form method="post" action="/test2.aspx">
<input type="text" name="testField" /><input type="submit" value="Go" />
</form>
</body>
</html>
=========================
=== test2.aspx.cs =======
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class test2: System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
foreach (string param in Request.Form)
{
Response.Write(param + "=" + Request.Form[param] + "<br />");
}
}
}
=========================
(test2.aspx is empty except the default stuff Visual Studio adds when creating a new web form)
When I build this and load it in my browser, there is nothing output on test2.aspx. HOWEVER, if I debug it, using F5 in Visual Studio, then it works as expected.
I have tried removing the "Form" and just looking for the POSTed value in Request.Params. When I do that, I see all of the request values, cookies, etc, but still not the form field value (again, it does show up, as expected, when debugging).
What am I doing wrong, here? Please help!
Thanks