Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
4.33/5 (2 votes)
See more:
Hi!,

Suppose I have two pages test1.aspx and test2.aspx. I have a control inside test1.aspx and i need to access that control value in test2.aspx without state management. HAve any idea?.
Posted
Comments
Suvendu Shekhar Giri 13-Aug-15 2:28am    
Without state management?
What do you mean by that?
and why you want to do that?

Have a look at this link-
How to: Pass Values Between ASP.NET Web Forms Pages[^]
Sergey Alexandrovich Kryukov 13-Aug-15 3:00am    
I think the question is clear enough and reasonable, especially when a universal approach is desired. It really makes sense.
Please see Solution 1.
—SA
F-ES Sitecore 13-Aug-15 4:30am    
You should try and get your head around the way websites etc work, it will help you greatly in general. Unlike windows forms, a "page" only exists when it is being rendered. After that it is gone, it no longer exists. So you can't access previous pages in the "current page" as they no longer exist. You need to look into various state management techniques that will let you keep old values in a way that works with what you're doing. Examples are putting data in hidden form fields, keeping it in the Session server-side, keeping it in cookies, keeping it in the Cache etc, they all have pros and cons.

1 solution

This is one of the possible approaches, perhaps the most universal one, because it does not depend on the server-side technology and will work even if you don't use any: https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage[^].

See also:
https://en.wikipedia.org/wiki/Web_storage[^],
https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Storage[^].

For more general case, when you need to store the whole data structure, not just one string, at a single key, you can use serialization using JSON. I demonstrated a complete code sample in this section of my article: JavaScript Calculator, 7. Dynamic Strict Mode Switching and Web Storage.

—SA
 
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