Total Page Preview:   000000000566

What is view state in ASP.NET in English and Hindi

 

 

 

View state in ASP.NET in English:

View state is a mechanism used in ASP.NET to maintain the state of controls on a web page across postbacks. When a page is posted back to the server, the view state is used to restore the values of the controls to their previous state. This allows web developers to create rich and interactive web pages that retain user input and selections.

 
Here's an example of using view state in ASP.NET using C#:

 

In this example, a simple web form is created with a text box, a button, and a label control. When the user enters text into the text box and clicks the button, the text is displayed in the label control.

 

 

In the code-behind file, the Page_Load event is used to initialize the view state when the page is first loaded. The Button1_Click event is used to update the label control with the text entered in the text box, along with a count of how many times the button has been clicked.
 
The count value is stored in the view state using a key-value pair. When the button is clicked, the count value is retrieved from the view state, incremented, and then stored back in the view state for the next postback.
 
This example demonstrates how view state can be used to maintain the state of controls on a web page across postbacks, allowing web developers to create rich and interactive web applications.
 
 
 
 
 
View state in ASP.NET in Hindi:
 
View state ek mechanism hai jo ASP.NET mai use kiya jata hai controls ki state ko postbacks ke bich maintain karne ke liye. Jab ek web page server ko postback karta hai, view state controls ke values ko unke previous state me restore karne ke liye use kiya jata hai. Isse web developers rich aur interactive web pages create kar sakte hai jo user input aur selections ko retain karte hai.
 
Yahan ek C# ka view state example diya gaya hai:
 
 
 
Is example mai, ek simple web form hai jisme ek text box, ek button, aur ek label control hai. Jab user text box mai text enter karta hai aur button par click karta hai, text label control mai display hota hai.
 
 
 
Code-behind file mai, Page_Load event view state ko initialize karne ke liye use kiya jata hai jab page first load hota hai. Button1_Click event label control mai text ko update karne ke liye use kiya jata hai, sath hi sath button click count ko bhi maintain kiya jata hai.
 
Count value ek key-value pair ke roop mai view state mai store kiya jata hai. Jab button par click kiya jata hai, count value view state se retrieve ki jati hai, increment ki jati hai, aur fir view state mai store ki jati hai next postback ke liye.
 
Is example se demonstrate hota hai ki view state kaise use kiya jata hai controls ki state ko postbacks ke bich maintain karne ke liye, jisse web developers rich aur interactive web applications create kar sakte hai.

 

 

 

 

Thank You

About Author

Brijesh Kumar

Database Developer

I have more then 6 years Experience in Microsoft Technologies - SQL Server Database, ETL Azure Cloud - Azure SQL Database, CosmosDB, Azure Data Factory, PowerBI, Web Job, Azure Function, Azure Storage, Web Apps, Powershall and Database Migration On-Premise to Azure Cloud.
LinkedIn : https://www.linkedin.com



Comments


                           
                           

                           

                           

Facebook User: