1

提交表单时我没有收到任何数据。我会期待Request.Form.Count=2,但相反RequestForm.Count=0

任何援助将不胜感激。

<%@ 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>

部分代码

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
4

1 回答 1

2

您输入的字段缺少名称。确保添加它们:

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

现在在服务器上,您将同时获得foobar具有各自值的键。

于 2017-02-26T11:15:51.943 回答