写了两个方法都不太对.希望各位给予解决,谢谢!!!!!(不用验证控件)
代码如下:
1. public static bool isNull(string un, string pwd)
    {
       if((un=="")||(pwd==""))
        {
            return false;
        }
        else
        {
            return true;
        }
    }2. public static bool isnotNull(string un, string pwd)
    {
     if((un!="")&&(pwd!=""))
     {
         return true;
     }
     else
     {
         return false;
     }
    }

解决方案 »

  1.   


     public static bool isnotNull(string un,string pwd) 
            if((un.Length == 0) || (pwd.Length == 0)) 
              { 
                      return   true; 
              } 
              else 
              { 
                      return   false; 
              } 
            }
      

  2.   

    不好意思我写错了-_-public   static   bool   isNull(string   un,   string   pwd) 
            { 
                  if((un.Length != 0) && (pwd.Length != 0)) 
                    { 
                            return   true; 
                    } 
                    else 
                    { 
                            return   false; 
                    } 
            } 
      

  3.   

    不行,当只输入密码时还是显示都不为空.我的代码:DB.CS: public static bool isNull(string un, string pwd)
        {
            if ((un.Length != 0) &&(pwd.Length != 0))
            {
                return true; ;
            }
            else
            {
                return false;        
            }Default.aspx: protected void txtUserName_Click(object sender, EventArgs e)
        {
            string un = this.txtUserName.Text.Trim();
            string pwd = this.txtPassword.Text.Trim();
            if (DB.isNull(un,pwd))
            {            Response.Write("验证用户名和密码都不为空");
            }
            else
            {
                Response.Write("验证用户名或密码至少有一项为空");
            }
      

  4.   

    我发的那个就是 任意1个值为空都返回False
      

  5.   

    lz201048,谢谢你,但是当运行时,只输入密码还是会返回True,很奇怪.