webform1.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="test4_10.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
用户名:<asp:TextBox ID="txt_username" runat="server"></asp:TextBox>
<br />
密 码:<asp:TextBox ID="txt_pwd" runat="server" TextMode="Password" ></asp:TextBox>
<br />
评论:<br />
<asp:TextBox ID="txt_note" runat="server" TextMode="MultiLine" Height="45px" Width="199px"></asp:TextBox>
<br />
<asp:Button ID="btn_submit" runat="server" Text="提交" OnClick="btn_submit_Click" />
</div>
</form>
</body>
</html>
webform1.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace test4_10
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btn_submit_Click(object sender, EventArgs e)
{
if ((txt_pwd.Text.Length < 8) || (txt_pwd.Text.Length > 15))
{
Response.Write("<script>alert('密码在8位至15位之间。');</script>");
return;
}
Response.Write("<script>alert('提交成功');</script>");
}
}
}