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;public partial class validate : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) {//getting info from demo.aspx using request.form string uname = Request.Form["txtuser"]; string pwd=Request .Form ["txtpwd"]; if (uname == "admin" && pwd == "admin123") {//setting the context with key and value Context.Items.Add("uname", uname);//transfering page to welcome.aspx Server.Transfer("welcome.aspx"); }//if not valid user this gets executed... else { Response.Write("not valid..."); } }}
public partial class welcome : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { //retrieving the context value string name = Context.Items["uname"].ToString(); Label1.Text = " welcome "+name; }}