FormSubmit.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FormSubmit.aspx.cs" Inherits="PassValuesBetweenPages.FormSubmit" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function submitform() {
document.forms[0].submit();
}
</script>
</head>
<body>
<form id="form1" method="post" action="FormSubmit.aspx">
<div>
<input name="test" value="test123" type="text" />
<a href="javascript: submitform()">Submit</a>
</div>
</form>
</body>
</html>
FormSubmit.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace PassValuesBetweenPages
{
public partial class FormSubmit : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Form["test"] != null)
{
string strTest = Request.Form["test"].ToString();
Response.Write("Form POST : " + strTest);
}
}
}
}
沒有留言:
張貼留言