2016-04-04 8 views
-1

以下のコードで私のページにバリデーションを追加したいと思います。Page Validation

CS1525:無効な表現用語「}」

私は、彼らはすべての必要とされるすべての括弧を確認しかし、それはエラーを与えています。誰かが私を助けてくれますか?

private Boolean pageValidate() 
    { 
     try 
     { 
      if (TextBox4.Text == "") 
      { 
       alert("Please Semester and year of 1st class attended at OU* "); 
       return (false); 
      } 
      else if (DropDownList1.SelectedValue.Substring(0, 2) == "--") 
      { 
       alert("Please select your current major."); 
       return (false); 
      } 
      else if (UpdatedClass1.SelectedValue.Substring(0, 2) == "--") 
      { 
       alert("Please select one action."); 
       return (false); 
      } 

      else if (UpdateClassRadioButton1.SelectedValue.Substring(0, 2) == "--") 
      { 
       alert("Please select Major/Minor."); 
       return (false); 
      } 

      else if (DropdownListMajorMinor.SelectedValue.Substring(0, 2) == "--") 
      { 
       alert("Please select the change of major/Minor you are requesting.."); 
       return (false); 
      } 

      else 
       return (true); 
     } 
     catch (Exception e) 
     { 
      return (false); 
     } 
    } 

    protected void btnSubmit1_Click(object sender, System.EventArgs e) 
    { 
     if (pageValidate()) 

     // Internweb.DBManipulator dbMangler = new DBManipulator(); 
     // dbMangler.InsertValuesIntoDB(TextBox4.Text, CheckBox1.Checked, CheckBox2.Checked, DropDownList1.Items, DropdownListMajorMinor.Items,); 
    } 

エラーメッセージ:CS1525:無効な表現用語 '}'

答えて

0

あなたはそれが真である場合に実行するなしブロックでif文を持っています。角括弧を追加すると、エラーが消えます。また、if文がそこにある理由を調べて、今のところ何もしないため、その中にいくつかのコードを追加する必要があります。

if (pageValidate()) 
{ 

} 
+0

ご返信ありがとうございます。出来た :) – amc