Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.NET C# Newb - Form fields not posting???

Status
Not open for further replies.

joepeacock

Programmer
Nov 5, 2001
74
US
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.
 
As this particular forum is focussed on classic ASP you may do better in forum855

If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top