新建一HtmlPage1.html,如下post发送()

<body>
  <form enctype="multipart/form-data" action="WebForm1.aspx" method="post">

         <label for="txtname">账号:</label>
         <input type="text" id="txtname" name="username" /><br />
         <input type="submit"  value="提交"/>

</form>
</body>

然后在 WebForm1.aspx 的Page_Load 中接受Form表单提交的数据

        protected void Page_Load(object sender, EventArgs e)
        {
            //取得表單中所有的鍵名
            string[] name = Request.Form.AllKeys;
            for (int i = 0; i < name.Length; i++)
            {
                //取得表單中所有的值
                string[] value = Request.Form.GetValues(i);
                //遍历输出 '键' 和 '值' 
                for (int j = 0; j < value.Length; j++)
                {
                    Response.Write(name[i] + "=" + value[j] + "<br/>");
                }
            }
        }

 

仅以此做记录

 

相关文章:

  • 2021-12-21
  • 2021-12-09
  • 2021-12-09
  • 2021-11-28
  • 2021-10-03
  • 2018-09-10
猜你喜欢
  • 2021-12-21
  • 2021-12-09
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
相关资源
相似解决方案