尝试从以下表单发布数据时出现 System.String[] 错误是我的示例代码。
默认.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox id="AccidentDetailsDate" runat="server" />
<br /><br />
<asp:Button ID="Button1" Text="Submit" runat="server" />
</div>
</form>
</body>
</html>
默认.aspx.cs:
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
public void Page_Load(object sender, EventArgs e)
{
var AccidentDate = Request.Form.GetValues("AccidentDetailsDate");
Response.Write(AccidentDate);
}
}
如果有人可以帮助我克服这个障碍,我将不胜感激,我花了最后 3 个小时试图解决它!