⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 default.aspx.cs

📁 这是asp.net^和Visual C++Sharp编写的串并口通讯的书籍 源代码
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
      

    }
    public bool ifLower(char chr)//检查字符是否为小写字母
    {
        if (chr >= 'a' && chr <= 'z')
            return true;
        else
            return false;
    }
    public bool ifUpper(char chr)//检查字符是否为大写字母
    {
        if (chr >= 'A' && chr <= 'Z')
            return true;
        else
            return false;
    }
    protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
    {

        if (this.txtPwd.Text=="")
        {
            args.IsValid = false;
            CustomValidator1.ErrorMessage = "密码不能为空";
        }
        else if(this.txtPwd.Text.Length<7)
        {
            args.IsValid = false;
            CustomValidator1.ErrorMessage = "用户密码长度不能小于7";
        }
        else
        {
            bool findLower = false;
            bool findUpper = false;
            //循环判断输入字符串,是否带有大小写字母
            for (int i = 0; i < this.txtPwd.Text.Length; i++)
            {
                if (findLower == false)
                    findLower = ifLower(Convert.ToChar(this.txtPwd.Text.Substring(i, 1)));
                if (findUpper == false)
                    findUpper = ifUpper(Convert.ToChar(this.txtPwd.Text.Substring(i, 1)));
            }
            if (findLower == true && findUpper == true)
            {
                Label2.Visible = true;
                Label2.Text = "用户注册成功!";
                args.IsValid = true;
            }//符合密码大小写混合字母 }
            else
            {
                args.IsValid = false;
                CustomValidator1.ErrorMessage = "用户密码必须包含大小写字母!";

            }//不符合密码大小写混合字母
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {

    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -