Program 1: Program to demonstrate use of View state
Coding:
Output:
Program 2: Program to demonstrate use of Cookies
Coding:
Output:
Program 3: Program to demonstrate use of query string
Design View:
Coding:
protected void Page_Load(object sender, Eventargs e)
{
string fname=[Link][“firstname”];
string lname=[Link][“lastname”];
[Link]=”Welcome:” +fname +” “ +lname;
}
Output:
Program 4: Program to demonstrate use of hidden form field
Design View:
Coding:
Output:
Program 5: Program to demonstrate use of Application State
Design View:
Coding:
[Link]:
Application_Start() Event:
Application [“user”]=0;
protected void Page_Load(object sender, EventArgs e)
{
Application["user"] =
Convert.ToInt32(Application["user"]) + 1;
[Link] = Application["user"].ToString();
}
Output:
Program 6: Program to demonstrate use of Session State
Design View:
Coding:
protected void Button1_Click(object sender, EventArgs e)
O
{
Session["user"] = [Link];
[Link]("[Link]")
}
protected void Page_Load(object sender, EventArgs e)
{
if (Session["user"] != null)
[Link] = Session["user"].ToString();
}
Output:
After clicking the button
Program 7: Program to demonstrate use of Session State
Design View:
Coding:
[Link]:
Session_Start() Event:
Session [“user”]=0;
protected void Page_Load(object sender, EventArgs e)
{
Session["user"] =
Convert.ToInt32(Session["user"]) + 1;
[Link] = Session["user"].ToString();
}
Output: