How To Use Session Variable?

By Goniey N (Mr. G)

Use Of Session Variable. Use One Form(Source.aspx) Value In Another Form(Destination.aspx).

//Source.aspx.cs Drag One Button In Window Form & Named “BtnNext”….

private void BtnNext_Click(object sender, System.EventArgs e)
{
    
//Drag Two TextBox In Window From & Named “TxtUserName” & “TxtSystemName”...
    
//Store Values In Two Session Variable From The TextBoxes...
    
  
Session["UserName"]=TxtUserName.Text;
  
Session["SystemName"]=TxtSystemName.Text;
  
Server.Transfer("Destination.aspx");
}





//Destination.aspx.cs Drag Two Labels In Window Form Named “LblUName” & “LblSName”…

private void Page_Load(object sender, System.EventArgs e)
{
    
//Store Session Variables Value In The Lables….
    LblUName.
Text=Session["UserName"].ToString();
    LblSName.
Text=Session["SystemName"].ToString();

    
//Remove Both Session Variable...
  
Session.Remove("UserName");
  
Session.Remove("SystemName");
}

How To Use Session Variable?  (1755 Views)