Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want show values in next page by using session varibles plz tell me any one....

this is my code....

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void btnsubmit_Click(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            Response.Write("you have sucessfully registred...!!!");
        }
    }

    protected void btnsubmit_Click1(object sender, EventArgs e)
    {
        Session["DEMO_SESSION"] = txtname.Text;
        Response.Redirect("default3.aspx");
    }

another form code:-
protected void Page_Load(object sender, EventArgs e)
   {
       TextBox1.Text = Session["DEMO_SESSION"].ToString();
   }


but I am getting only one name only but I want all information what i insert in the form?
Posted
Updated 13-Feb-12 23:58pm
v2
Comments
Varun Sareen 14-Feb-12 5:59am    
Edit For: added pre tag

session variable

Pls go thru this link

Values in next page


if (TextBox1.Text!= "")
{
Session["DEMO_SESSION"] = TextBox1.Text;
Session.Timeout = 1;
Response.Redirect("Default2.aspx");
}
else
{
Session["DEMO_SESSION"] = "";
}
}
}
 
Share this answer
 
v3
Than Whats The Problem Add more Variable in session

like :

C#
Session["DEMO_SESSION1"] = txtname.Text;
Session["DEMO_SESSION2"] = txtadd.Text;
Session["DEMO_SESSION3"] = txtphone.Text;
 
Share this answer
 
Comments
rockpune 14-Feb-12 6:02am    
thank u sir
CRDave1988 14-Feb-12 6:04am    
welcome mark it as answer if it solve ur problem
 
Share this answer
 
Hi,

problem is solved by following


Assign all your text box values to sessions


<pre lang="c#">protected void btnsubmit_Click1(object sender, EventArgs e)
{
Session["S_Name"] = txtname.Text;
Session["S_Address"] = txtadd.Text;
Session["S_Phone"] = txtphone.Text;
}</pre>


And then get that session values on

<pre lang="c#">
protected void Page_Load(object sender, EventArgs e)
{

txtname.Text=Session["S_Name"].ToString();
txtadd.Text=Session["S_Address"].ToString();
txtphone.Text=Session["S_Phone"].ToString();
}
</pre>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900