Let's see, I'll explain in more detail what happened. I have a texbox and a button; what I want is to enter data to the texbox and when I click on the button I redirect to another page getting the value of that texbox. For that I am session to store and then in the other window that will redirect me and show it.
This is the image of my codebing when I click on the button.
Now to get the value of that session and to show in a texbox what I do is in load (), like this code in my webform2.
Now when I run the application, log into my webform1.aspx and put the name in the texbox: "name1" if you redirect me to webform2.aspx and if my "name1 is displayed ".
Now the problem is that when I open another tab and put the webform1.aspx and place in the texbox nombre2 if I address to the other page and if the second name that I placed now comes back to the previous tab and update the page the name has changed and that is the problem.
How could it not be changed or what method is to replace the session ?, Since what I show is something small but according to my question because in my system the same thing happens and I would like to have the name that is placed, imagine that a user enters and registers something and is well registered with his first name that he entered but then he enters with his other user and registers everything. Now in the session it will take it with the second user and not with the first one and it would cause problems.
This is the Code of WebForm1
Front-End
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click"/>
</div>
</form>
Back-End
protected void Button1_Click(object sender, EventArgs e)
{
Session["usuario"] = TextBox1.Text;
Response.Redirect("WebForm2.aspx");
}
Webform2 Code
Front-End
<form id="form1" runat="server">
<div>
<asp:Label ID="lbl1" runat="server" Text="Label"></asp:Label>
</div>
</form>
Back-End
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (Session["usuario"].ToString() == null)
{
Response.Redirect("WebForm1.aspx");
}
else
{
lbl1.Text = Session["usuario"].ToString();
}
}
}