0% found this document useful (0 votes)
16 views7 pages

ASP.NET State Management Examples

The document outlines several programs demonstrating different state management techniques in web applications, including View State, Cookies, Query Strings, Hidden Form Fields, Application State, and Session State. Each program includes coding examples and expected outputs. The focus is on how to manage user data and interactions through various methods in a web environment.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views7 pages

ASP.NET State Management Examples

The document outlines several programs demonstrating different state management techniques in web applications, including View State, Cookies, Query Strings, Hidden Form Fields, Application State, and Session State. Each program includes coding examples and expected outputs. The focus is on how to manage user data and interactions through various methods in a web environment.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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:

You might also like