Click here to Skip to main content
15,914,500 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to maintain value in different pages.
Posted
Comments
member60 23-Nov-11 2:00am    
try to elaborate your question
Prasad_Kulkarni 23-Nov-11 2:14am    
give some more explanation of your question..
jeet786 23-Nov-11 2:23am    
Please ask your question in detail!

State management is the process by which you maintain state and page information over multiple requests for the same or different pages.
 
Share this answer
 
v2
In Web Applications
---------------------
Use State Management
-Client side
-Server Side

Example of Server Side State Management
Page1
--------
eg. Session["Name"]=txtBox1.Text;

Page2
------
string sName=(string)Sesion["Name"];


In case of Windows application, Either you can use Properties or Use parameterised constructor to do the same.

Using Parameterised Constructor
---------------------
Write the following code on button click event of Form1
Collapse | Copy CodeForm5 f=new Form5(textBox1.Text);
f.Show();

Get the value in the Form5 as
string sValue;
public Form5(string s)
{
sValue=s;
}Using Properties
-------------------
Define the property in Form2 as
Collapse | Copy Codeprivate string sValue;
public string Value
{
get{return value;}
set{value=sValue;}
}and use the value of the variable as well.

Setting the value of textBox1 in Form1 as:
Collapse | Copy CodeForm2 f=new Form2();
f.Value=textBox1.Text;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900