textBox.Text.Trim() == String.empty

解决方案 »

  1.   

    if (TextBox1.Text.Trim() == String.empty || TextBox2.Text.Trim() == String.empty)
    {
    Response.write("<script>alert('不能同时为空');</script>");
    }
      

  2.   

    if(string.IsNullOrEmpty(textBox1.Text) && string.IsNullOrEmpty(textBox2.Text))
    {
       button1.Enable=false;
    }
    else
       button1.Enable=true;或者也可以用js判断.
      

  3.   

    上面的是C#里的Button代码。如果用JS可以用onblur事件,
    if (document.getElementByID('TextBox1').value=='' ||document.getElementByID('TextBox1').value=='')
    {
    document.getElementByID('TextBox1').disable=true;
    }
    else
    {
    document.getElementByID('TextBox1').disable=false;}
      

  4.   

    string scp="{0}.disabled=({1}.value=='' && {2}.value=='');"
    scp=string.Format(scp,yourButton.ClientID,yourTextBox1.ClientID,yourTextBox2.ClientID);
    yourTextBox1.Attributes["onkeypress"]=scp;
    yourTextBox2.Attributes["onkeypress"]=scp;
      

  5.   

    if (document.getElementByID('TextBox1').value==""&&document.getElementByID('TextBox1').value=="")
    {
    document.getElementByID('TextBox1').disabled=true;
    }
    else
    {
    document.getElementByID('TextBox1').disabled=false;
    }