I want to display username in the top of all page.
Below is my code .
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnLogin_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand("select * from Userman where Username =@username and Password=@password", con);
cmd.Parameters.AddWithValue("@username", txtUsername.Text);
cmd.Parameters.AddWithValue("@password", txtPassword.Text);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
Admin();
}
else
{
ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language='javascript'>alert('Invalid Username and Password')</script>");
}
}
private void Admin()
{
if (txtUsername.Text == "admin" && txtPassword.Text == "123")
{
Response.Redirect("AdminHome.aspx");
}
else
{
Response.Redirect("UserHome.aspx");
}
}
Could you please help me on this