Click here to Skip to main content
15,916,945 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
first form.......

C#
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");
        Session["DEMO_SESSION1"] = txtpwd.Text;
        Response.Redirect("default3.aspx");
        Session["DEMO_SESSION2"] = txtpassword.Text;
        Response.Redirect("default3.aspx");
        Session["DEMO_SESSION3"] = txtadd.Text;
        Response.Redirect("default3.aspx");
        Session["DEMO_SESSION4"] = txtfull.Text;
        Response.Redirect("default3.aspx");
        Session["DEMO_SESSION5"] = DropDownList1.SelectedIndex;
        Response.Redirect("default3.aspx");


    }
    }




second form......

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Web.Security;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Default3 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        TextBox1.Text = Session["DEMO_SESSION"].ToString();
        TextBox2.Text = Session["DEMO_SESSION1"].ToString();
        TextBox3.Text = Session["DEMO_SESSION2"].ToString();
        TextBox4.Text = Session["DEMO_SESSION3"].ToString();
        TextBox5.Text = Session["DEMO_SESSION4"].ToString();
        TextBox6.Text = Session["DEMO_SESSION5"].ToString();



    }
}





error.....
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 18:
Line 19: TextBox1.Text = Session["DEMO_SESSION"].ToString();
Line 20: TextBox2.Text = Session["DEMO_SESSION1"].ToString();
Line 21: TextBox3.Text = Session["DEMO_SESSION2"].ToString();
Line 22: TextBox4.Text = Session["DEMO_SESSION3"].ToString();
Posted

in first form just replace this in button_click event..


C#
Session["DEMO_SESSION"] = txtname.Text;
Session["DEMO_SESSION1"] = txtpwd.Text;
Session["DEMO_SESSION2"] = txtpassword.Text;
Session["DEMO_SESSION3"] = txtadd.Text;
Session["DEMO_SESSION4"] = txtfull.Text;
Session["DEMO_SESSION5"] = DropDownList1.SelectedIndex;
Response.Redirect("default3.aspx");



Use this and don't forget to accept my answer...

Try it.. Best of luck.. :)
 
Share this answer
 
v2
Comments
rockpune 14-Feb-12 6:28am    
than u very much brother
Response.Redirect("default3.aspx"); will come only once at the end of function.

mark solution as answer when u got ur problem solved.
 
Share this answer
 

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