Len White
Len White

Reputation: 992

aspx Request.Form.Count=0

I am not getting any data when submitting a form. I would expect Request.Form.Count=2, but instead RequestForm.Count=0.

Any assistance would be appreciated.

<%@ Page Language="VB" EnableViewState="false" AutoEventWireup="false" CodeFile="Default2.aspx.vb"     Inherits="ecomm_Default2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
    <form id="form1" method="post">
        <input id="textfield" type="text" value="My Text" />
        <input type="submit" value="Send it" />
    </form>
</body>
</html>

Code behind part

Imports System.Diagnostics
Partial Class ecomm_Default2
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        If Request.HttpMethod = "POST" Then
            Debug.WriteLine(Request.Form.Count)
        End If
    End Sub
End Class

Upvotes: 1

Views: 1568

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038780

You input fields are missing names. Make sure you add them:

<input id="textfield" name="foo" type="text" value="My Text" />
<input type="submit" name="bar" value="Send it" />

Now on the server you will get both foo and bar keys with their respective values.

Upvotes: 2

Related Questions