i have two .aspx page, first(home) page having a label1 and second (register)page having user name and passwrod now i want when anyone fill that register form and click that button the user name which he entered in first textbox should be show on the label1 which is on the first(home) page.
waiting... help me hurry
Thanks
Chester !
Loading
shyamalaPosted Nov 27, 2009, 5:16 AM
protected void button1_Click(object sender, EventArgs e)
{
session["username"]=TextBox1.Text;
}
in home page
protected void Page_Load(object sender, EventArgs e)
{
if (Session["username"].ToString() != "")
{
dt = con.DBExecute("select username from tablename");
Label1.text=dt.Rows[0]["username"].ToString();
}
}
one info:if u r using session means no need to pass the value via response.redirect
Kirtan PatelPosted Nov 26, 2009, 10:58 AM
if my answer helps you then check "Do you like this answer" check box :)
Page 1 Code
----------------
protected void Page_Load(object sender, EventArgs e)
{
if (Session["Username"] != null)
{
Label1.Text = Session["Username"].ToString();
}
}
Registration Page's Code
----------------------
protected void button1_Click(object sender, EventArgs e)
{
Session["Username"] = txtUsername.Text.Trim();
Response.Redirect("Page1.aspx");
}