本节为你讲解ASP.NETWebPagesHTML表单。
表单是 HTML 文档中放置输入控件(文本框、复选框、单选按钮、下拉列表)的部分。
创建一个 HTML 输入页面
Razor 实例
<html><body>
@{
if (IsPost) {
string companyname = Request[“companyname”];
string contactname = Request[“contactname”];
<p>You entered: <br />
Company Name: @companyname <br />
Contact Name: @contactname </p>
}
else
{
<form method=”post” action=””>
Company Name:<br />
<input type=”text” name=”CompanyName” value=”” /><br />
Contact Name:<br />
<input type=”text” name=”ContactName” value=”” /><br /><br />
<input type=”submit” value=”Submit” class=”submit” />
</form>
}
}
</body>
</html>