Tuesday, February 15, 2011

How to transfer values from one page to another page using Sessions

Hi friends,By using Sesions we can store the values and we can transfer the values from page to another page.

In this i would like to explain how to transfer registration form details from one page to another page.


First,Open the Registration.aspx.cs page and write the following code  in page load

protected void Page_Load(object sender, EventArgs e)
{
    Session["txt1"] = txt_uname.Text;
        Session["txt2"] = txt_pwd.Text;
        Session["cpwd"] = txt_cpwd.Text;
        Session["txt3"] = txt_age.Text;
        Session["txt4"] = txt_email.Text;
        Session["txt5"] = genderRadioButton.SelectedItem.ToString();
        Session["txt6"] = txt_mobile.Text;
        Session["txt7"] = txt_date.Text;
        Session["txt8"] = ddlCountry.SelectedItem.ToString();
        Session["txt9"] = ddlState.SelectedItem.ToString();
}


next,In which page you would like to display the Details of the Registration form..if you would like to display the values in Display.aspx page.just copy the code in the Page load
 protected void Page_Load(object sender, EventArgs e)
    {
        //for session using
        lbl_duname.Text = (string)Session["txt1"];
        lbl_dpwd.Text = (string)Session["txt2"];
        lbl_dage.Text = (string)Session["txt3"];
        lbl_demail.Text = (string)Session["txt4"];
        lbl_dgender.Text = (string)Session["txt5"];
        lbl_dmobile.Text = (string)Session["txt6"];
        lbl_ddate.Text = (string)Session["txt7"];
        lbl_dcountry.Text = (string)Session["txt8"];
        lbl_dstate.Text = (string)Session["txt9"];
       
    }
That's it...Happy Coding Friends

developercode
About the Author
Sayyad is a Software Engineer, Blogger and Founder of Developers Code from India.His articles mainly focus on .Net (Web and Windows based applications), Mobile Technologies (Android,IPhone,BlackBerry) and SEO.

Labels: , , , , ,

4 Comments:

At March 31, 2011 at 1:41 AM , Anonymous Victor Tiago said...

Thankyou very very much i´m sheaching fo this,

hugs

 
At March 31, 2011 at 8:40 AM , Blogger Developers Code said...

Welcome..........

 
At April 24, 2011 at 9:42 AM , Anonymous Wordpress Dicas said...

Very Nice!

 
At June 28, 2011 at 10:16 AM , Anonymous Tanisha said...

Welcome..........

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home