如何将值从HTML页面传递到ASPX?

时间:2014-06-08 05:12:06

标签: html asp.net

我有两个文件html和.aspx,这两个文件都有两个文本框。当用户文件在html页面的文本框中输入值并单击“提交”时,应在.aspx页面中填写值。我尝试了很多方法,但无法得到我需要的东西。

1 个答案:

答案 0 :(得分:2)

您可以像这样使用简单的HTML表单GET方法:

//你的html文件,例如HtmlPage1.html

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"> <head>
<title></title> </head> <body>
<form action="WebForm1.aspx" method="get">
    Choose your favorite subject:
    <button name="subject" type="submit">send my value</button>
    <input id="name" name="name"  type="text" />
</form> </body> </html>

//你的aspx文件,例如WebForm1.aspx的

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="AssessorsLounge.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">
<title></title> </head> <body>
<form id="form1" runat="server">
<div>
<%: Request.QueryString["name"].ToString() %>
</div>
</form> </body> </html>

您可以在www.w3schools.com

上了解有关html和asp.net的更多信息
相关问题