📄 htmlform.aspx
字号:
<%@ Import namespace="System.IO" %>
<html>
<head>
<title>HTML表单举例!</title>
<script Language="C#" runat="server" >
void Page_Load()
{
NameValueCollection coll;
if(Request.HttpMethod == "GET")
{
coll = Request.QueryString;
}
else if(Request.HttpMethod == "POST")
{
coll = Request.Form;
}
else
{
Text1.Text = "未知的传送方法!";
return;
}
// Verify if the password is identical
if( coll["password"] != coll["repassword"] )
{
Text1.Text = "两次输入的密码不同,注册失败!";
return;
}
try
{
string filename = Request.PhysicalApplicationPath + "\\" + coll["name"] + ".txt";
StreamWriter writer = File.CreateText(filename);
writer.WriteLine("name={0}", coll["name"]);
writer.WriteLine("password={0}", coll["password"]);
writer.WriteLine("birthday={0}年{1}月", coll["year"], coll["month"]);
writer.WriteLine("description={0}", coll["description"]);
writer.Close();
}
catch(Exception e)
{
Text1.Text = e.ToString();
}
Text1.Text = coll["name"] + "注册成功!";
}
</script>
</head>
<body>
<asp:Label id="Text1" runat="server" />
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -