asp.net4.5练习~test4-2
发布日期:2021-05-06 21:15:26 浏览次数:14 分类:原创文章

本文共 1444 字,大约阅读时间需要 4 分钟。

 webform1.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="test4_2.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="txtName" runat="server" AutoPostBack="True" OnTextChanged="txtName_TextChanged"></asp:TextBox>       <asp:Label ID="lblValidate" runat="server"></asp:Label><br />        密码:<asp:TextBox ID="txtPassword" runat="server" TextMode="Password"></asp:TextBox><br />        E-mail:<asp:TextBox ID="txtMail" runat="server" TextMode="Email"></asp:TextBox><br />        <asp:Button ID="btnSubmit" runat="server" Text="确认" />    </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_2{    public partial class WebForm1 : System.Web.UI.Page    {        protected void Page_Load(object sender, EventArgs e)        {            txtName.Focus();        }        protected void txtName_TextChanged(object sender, EventArgs e)        {            if (txtName.Text == "admin")            {                lblValidate.Text = "此用户已存在";            }            else            {                lblValidate.Text = "用户名可用";            }        }    }}

 

上一篇:asp.net4.5练习~test4-3
下一篇:asp.net4.5练习~test4-1

发表评论

最新留言

路过按个爪印,很不错,赞一个!
[***.219.124.196]2025年04月05日 07时52分39秒