Israel

Israel

  • 631
  • 1.3k
  • 217.4k

Want to see the real username appear on the next page

Jan 23 2014 6:46 AM

Hi!
I putted a "label" on my next page that I want to mention the real username after log in
Then this username should appear on the next page ONLY when the username and password are correct
How can I do it? this my codes:


protected void log_Click(object sender, EventArgs e)
  {
  SqlDataSource sds = new SqlDataSource();
  sds.ConnectionString = ConfigurationManager.ConnectionStrings["master"].ToString();  sds.SelectParameters.Add("username", TypeCode.String, this.username.Text);
  sds.SelectParameters.Add("password", TypeCode.String, this.password.Text);
  sds.SelectCommand = "SELECT * FROM [myTb] WHERE [username] = @username AND [password] = @password"; 
  DataView dv = (DataView)sds.Select(DataSourceSelectArguments.Empty);
  try
  {
  if (dv.Count == 0)
  {
  this.lblinfo.ForeColor = System.Drawing.Color.Red;
  this.lblinfo.Text = "Invalid username and password!";
  return;
  }
  else
  {
 
  FormsAuthentication.RedirectFromLoginPage(username.Text, true);
  Response.Redirect("~/English/Visual.aspx");
  //It's here where I need the codes
 
 
  }
  }
  catch
  {
  }
  finally
  {
  }
  }
}





Answers (3)