First, you can remove most of the brackets:
if (string.IsNullOrEmpty(TxtUsername.Text))
LblMessage.Text = "Enter Username";
else if (TxtUsername.Text.Length < 5)
LblMessage.Text = "Username Should be Minimum 5 character";
else if (!validateStr(mRegExUsername, TxtUsername.Text))
LblMessage.Text = "Check Note below for guidelines.";
else if (RDBtnSignup.Checked && BLLLoginDetails.Instance.CheckUsernameAvailability(TxtUsername.Text) != 1)
LblMessage.Text = CISMessages.NotAvailableMsg;
else
{
secemail.Visible = !RDIsOwner.Checked;
e.Cancel = false;
}
But then, it's most likely that this is a body of some event handler and
e.Cancel
was not assigned in this handler before. If so, it is already null, so you can remove more three lines:
if (string.IsNullOrEmpty(TxtUsername.Text))
LblMessage.Text = "Enter Username";
else if (TxtUsername.Text.Length < 5)
LblMessage.Text = "Username Should be Minimum 5 character";
else if (!validateStr(mRegExUsername, TxtUsername.Text))
LblMessage.Text = "Check Note below for guidelines.";
else if (RDBtnSignup.Checked && BLLLoginDetails.Instance.CheckUsernameAvailability(TxtUsername.Text) != 1)
LblMessage.Text = CISMessages.NotAvailableMsg;
else
secemail.Visible = !RDIsOwner.Checked;
But I doubt that it all makes sense, because the code does not look properly designed. We just did not touch your logic, and this is what should really be improved. To improve it more, some information on what do you want to achieve would be needed.
—SA