Jaya Prakash

Jaya Prakash

  • 541
  • 2.3k
  • 65.9k

How To Handle Exceptions when using if else conditions

Oct 6 2023 9:03 AM
protected void btnSubmit_Click(object sender, EventArgs e)
{
    try
    {
        if (txtName.Text == "Jaya" && txtPwd.Text == "1234")
        {
            Server.Transfer("Retailer.aspx");
        }
        else
        {
            Server.Transfer("Login.aspx");
        }
    }
    catch(Exception ex)
    {
        oExceptionManager.LogError(ex.Message, "Error From btn btnSubmit_Click in Login.aspx.cs");
    }
}

in my code the catch block is executing if it is true or false but i want to execute when i got false condtions pls modify my code


Answers (1)