I want to add validation to my page with below code. But it is giving an error :
CS1525: Invalid expression term '}'
I checked all parenthesis they are all required. Can someone please help me.
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,);
}
Error Message: CS1525: Invalid expression term '}'
答案 0 :(得分:0)
You have an if statement with no block to execute if it is true. Adding brackets will make the error go away. You should also look into why that if statement is there and add some code inside of it because right now it will do nothing.
if (pageValidate())
{
}