Home ProgrammingASP.NET State Management in ASP.NET

State Management in ASP.NET

by John Bhatt
0 comment 423 views

Hi Everybody, I am once back with a blog/article/tutorial whatever you think/call it.

State Management in ASP.NET:

HTTP Protocol is State less protocol. In Simple Language, Each and Every time We send a request to server, this is New to server.

To Understand this, suppose you took One Textbox and Two Buttons like in Image below:
State Management in ASP.NET 2

Now, the task is To Enter Number in Textbox and Click in First Button to Convert to Integer format and then Click Second button to Print Square of Converted Integer in Textbox. What will you do? Let’s look at code what I did here.

protected void Page_Load(object sender, EventArgs e)
   int x;
protected void Button1_Click(object sender, EventArgs e)
   x = Convert.ToInt32(TextBox1.Text);
protected void Button2_Click(object sender, EventArgs e)
   TextBox1.Text = Convert.ToString(x * x);

Now what would I get Result on Second Button Click event. Textbox Result will be 0 even I have entered any number. Don’t agree, try this at home.

This is Because, at the time of Button2 Click new request is send to server and Initial Value of X is picked from server which is 0.

To Prevent the Loose of Data each time we send request to server, ASP.NET have implemented concept of State Management.

State Management in ASP.NET

Types of State Management

State Management is divided into two parts according to Functionality.

1) User Based State Management in ASP.NET

2) Server Based State Management in ASP.NET

  • Session
  • Application
  • Profile

I am going to Describe all these States step by step in Different Posts.

All the Series has been posted on DotNetSpider at below Link Resources > Keep Reading.

0 comment

Related Articles

Leave a Reply

Do NOT follow this link or you will be banned from the site!