我有一个在线表格,其中有许多文本框,包括电子邮件 ID、密码和其他详细信息。当用户没有输入正确的信息时。我正在显示以下代码中显示的错误消息。我正在使用 SQL 的返回值。我正在尝试清除每个按钮单击的标签。谁能帮我?
protected void Button1_Click(object sender, EventArgs e)
{
{
{
SqlConnection sqlCon = new SqlConnection(strCon);
SqlCommand cmd = new SqlCommand("UpdateRequestAccess_Test", sqlCon);
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "UpdateRequestAccess_Test";
cmd.Connection = sqlCon;
----------Parameters are declared here--------
SqlParameter rpv = new SqlParameter();
rpv.DbType = DbType.Int32;
rpv.Direction = ParameterDirection.ReturnValue;
cmd.Parameters.Add(rpv);
try
{
sqlCon.Open();
cmd.ExecuteScalar();
int retValue = Convert.ToInt32(rpv.Value);
if (retValue == 10)
lblMessage.Text = "Request was sent successfully!";
if (retValue == 11)
Label2.Text = "*Email Address is already registered.";
if (retValue == 12)
Label3.Text = "*Passwords do not match.";
if (retValue == 13)
Label4.Text = "Sorry, Your application was already denied earlier.";
if (retValue == 14)
Label5.Text = "*Please select an option 'Yes' or 'No' under Select Online Tools.";
if (retValue == 15)
Label6.Text = "*Please enter the information in the text boxes above.";
if (retValue == 15)
Label7.Text = "*Please Select an option from the dropdown above.";
}
catch (Exception ex)
{
lblMessage.Text = ex.Message;
Label2.Text = ex.Message;
Label3.Text = ex.Message;
Label4.Text = ex.Message;
Label5.Text = ex.Message;
Label6.Text = ex.Message;
Label7.Text = ex.Message;
}
}
}
}