You can pass values from one page to another using Request.Params collection which returns collection of Form elements, Cookies, Server Variables and QueryString.
Login.aspx page:
private void Button1_Click(object sender, System.EventArgs e)
{
System.Collections.Specialized.NameValueCollection myCol = Request.Params;
string userName = Request.Params.Get("txtUserName");
Server.Transfer("SecondPage.aspx");
}
And the SecondPage.aspx which will receive the values looks something like this:
private void Page_Load(object sender, System.EventArgs e)
{
if(Request.Params.Get("txtUserName") != null)
{
string userName = Request.Params.Get("txtUserName");
Response.Write(userName);
}
}
Please keep in mind that I have used Server.Transfer and not Response.Redirect since I want to use the Collection from the old page. If I use Response.Redirect than it will make a trip to the server and I will loose the whole collection.