Click here to Skip to main content
15,921,028 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this is my code:
C#
protected void enablebutton()
   {

       If(item_name.text == "" || model.text == "" || company.text == "" || quantity.text == "");
       {
           Button1.enable = false;
       }
       else

       {
      Button1.enable = true;

   }


i am getting an error invalid expression else.

please suggest me something....
Posted

You had a semicolon (;) after the if-statement.
Remove that one and it should work.

C#
protected void enablebutton()
{

  if (item_name.text == "" || model.text == "" || company.text == "" || quantity.text == "")
  {
    Button1.enable = false;
  }
  else
  {
    Button1.enable = true;
  }
 
Share this answer
 
v2
You are getting error because your if condition is ending with semi-colon. Remove it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900