using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
string url;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Session["a"] = txt_username.Text.ToString();
Session["b"] = txt_password.Text.ToString();
Response.Redirect("screen.aspx");
}
}
screen.aspx code
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = Session["a"].ToString();
Label1.Text = Session["b"].ToString();
}
}
Design page
Default.aspx design page
Session.aspx design page
when i run default.aspx and click the button
the following error occurs
the resource cannot be found.
please help me. i want to retreive the username and password of default.aspx to session.aspx page using session please help me.
and send the correct code.what is wrong in my above code.

Satyapriya NayakRank #47 · 31.5K reputationPosted Mar 5, 2012, 4:22 AM EST
Default.aspx code
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Session._Default" %>
Default.aspx.cs code
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace Session
{
public partial class _Default : System.Web.UI.Page
{
protected void Button1_Click(object sender, EventArgs e)
{
Session["a"] = txt_username.Text.ToString();
Session["b"] = txt_password.Text.ToString();
Response.Redirect("screen.aspx");
}
}
}
screen.aspx code
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="screen.aspx.cs" Inherits="Session.Session" %>
screen.aspx.cs code
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace Session
{
public partial class Session : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
TextBox1.Text = Session["a"].ToString();
TextBox2.Text = Session["b"].ToString();
}
}
}
Thanks
If this post helps you mark it as answer