Click here to Skip to main content
15,915,501 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a page with some textbox's and with dropdownlist now i have used a .cs class with some properties and set properties class's object in .aspx page. Now I want to pass these values to the next page where i am calling another method of .cs class that returns datset and set to listview now i have problem that if i want to call that i need a separate object that sets separate values to properties means default values. Now i want to use previous values now what is the solution here to set the properties once and can use on other page but i have need a separate object to call the method i have no way to got now. So please help me overcome this problem.

e.g.
JobSearch.aspx.cs to Jobs.aspx.cs
Jobsearch has all the controls and Jobs just call the jobs.cs class method with new object.
Posted
Updated 14-Jul-11 2:27am
v2

Use Session. like this:
C#
//First page
MyClass c1 = new MyClass();
Session["MyClass"] = c1;

//Next page
MyClass c1 = Session["MyClass"] as MyClass;
if (c1 != null) {
 ...
}
 
Share this answer
 
Use sessions :
Example :

classtest t=new classtest() //object from a class callaed classtest
Session["obj"]=t;

now when you want to retrieve it juts do the following :

classtest n=new classtest()

n=Session["obj"];

Kindly notice that when saving object in session it should be serialized if you are not using inproc.

Hope this helps.
 
Share this answer
 
Comments
Satyendra Kumar(Analyst Programmer) 14-Jul-11 12:10pm    
but i had disabled the session in web.config and not want to use session in this page i know about session but if possible please tell me another solution.
mhamad zarif 15-Jul-11 2:44am    
If you dont want to use sessions then i think that you can use application for example which also can transfer objects between pages.
Have a look at this article. Should help.

http://aspalliance.com/151_Passing_Data_the_NET_way[^]
 
Share this answer
 
To manage Server side state, following site will help you go ahead with proper solution as per your need,

[1] ASP.NET State Management Recommendations[^]
[2] ASP.NET State Management Overview[^]
[3] ASP.NET Session State Overview[^]

Hope it helps :)
 
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