protected void Page_Load(object sender, EventArgs e) { if (Session["USER_NAME"] != null) { Response.Redirect("Dashboard.aspx"); } TextUserName.Focus(); }
public void TextUserName_TextChanged(object sender, EventArgs e) { if (!string.IsNullOrEmpty(TextUserName.Text)) { alert_box.Visible = false; OracleConnection conn = new OracleConnection(strConnString); conn.Open(); OracleCommand cmd = new OracleCommand(); cmd.Connection = conn; cmd.CommandText = "select * from NRC_USER where USER_NAME = '" + TextUserName.Text + "'"; cmd.CommandType = CommandType.Text; OracleDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { CheckUsername.Text = "<label class='control-label'><i class='fa fa-times-circle-o'></i> User name is not available</label>"; CheckUsername.ForeColor = System.Drawing.Color.Red; TextUserName.Focus(); BtnAdd.Attributes.Add("aria-disabled", "false"); BtnAdd.Attributes.Add("class", "btn btn-primary disabled"); } else { CheckUsername.Text = "<label class='control-label'><i class='fa fa fa-check'></i> User name is available</label>"; CheckUsername.ForeColor = System.Drawing.Color.Green; TextUserName.Focus(); BtnAdd.Attributes.Add("aria-disabled", "true"); BtnAdd.Attributes.Add("class", "btn btn-primary active"); } } else { CheckUsername.Text = "<label class='control-label'><i class='fa fa-hand-o-left'></i> User name is not blank</label>"; CheckUsername.ForeColor = System.Drawing.Color.Red; TextUserName.Focus(); } }