a.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<form method="post" target='_blank' action="http://192.168.1.1/b.aspx?test_str=this_is_url_string">
<input id='txt1' name='txt1' type='text'><br>
<textarea name='response_msg' id='response_msg' rows='5' cols='50'></textarea><br>
<input name='random_code' id='random_code' type='hidden' value='9906c3bd9f5147b9947d07a388c20010'>
<input name='email' type='hidden' value='aaa@aaa.com.tw'>
<input id="Button1" type="submit" value="送出" />
</form>
</body>
</html>
PS:Form傳值的物件一定要定義name='',否則aspx接不到值。
b.aspx
<%@ Page Language="C#" Debug="true"%>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
String aaa = Request.Form["txt1"].ToString(); //接取Form POST傳值
Response.Write("Form POST傳值 txt1 = " + aaa + "<br>");
String bbb = Request.Form["response_msg"].ToString();
Response.Write("Form POST傳值 response_msg = " + bbb.Replace("\r\n", "<br>") + "<br>");
String ccc = Request.Form["random_code"].ToString();
Response.Write("Form POST傳值 random_code = " + ccc + "<br>");
String ddd = Request.Form["email"].ToString();
Response.Write("Form POST傳值 email = " + ddd + "<br>");
String eee = Request.QueryString["test_str"]; //接取URL傳值
Response.Write("URL傳值 test_str = " + eee + "<br>");
}
</script>
<html>
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<form id="form1" runat="server">
<asp:Label ID="Label99" runat="server" Text=""></asp:Label>
</form>
</body>
</html>
留言列表