Solved

Can I store a class to a Page, like viewstate (for concurrently opened pages)?

Posted on 2008-06-19
5
203 Views
Last Modified: 2013-11-07
I have a web administration page that allows changing of website stuff like CSS styles, banners, images, page titles, etc. Currently, I store page inputs in a class, then into a session variable, just so the administrator can see the page before actually saving it to the file system. I'm running into a problem where the administrator has two admin pages opened in their browser and working on them concurrently, say tab1 and tab2. Since I'm storing the page inputs into a single session variable called (MyClass)Session["PageInputs"], the last opened page (tab2) overwrites tab1's page inputs in that session variable. You can imagine going back and forth from tab to tab can cause corruption and unintended data being saved to the wrong page with this methodology.

I'm trying to come up with a way where instead of storing the page inputs into a single session, each page has the page inputs stored. This way I can open multiple pages and work on them currently. Is there a way to store a class to the Page? I couldn't find a viewstate for the "Page" class. Maybe there's another way to store a class per opened page and work on them concurrently?
0
Comment
Question by:bemara57
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 16

Expert Comment

by:ororiole
ID: 21827780
Why not just store them in the viewstate it self?
           MyClass myAdminClass = new MyClass();
            ViewState["spam"] = myAdminClass;

            var savedClass = (MyClass)ViewState["spam"];

and mark your class as serializable:
[Serializable()]
public class MyClass
{ ...
}
0
 

Author Comment

by:bemara57
ID: 21827922
The thing is that I make changes to that class thru App_Code methods. I can't get a hold of the ViewState from App_Code can I?
0
 
LVL 16

Expert Comment

by:ororiole
ID: 21828582
How where you storing them into the Session object? thru HttpContextUtility?
0
 

Author Comment

by:bemara57
ID: 21830706
Ya, thru HttpContext.Current.Session, but I don't see that Current has any ViewState in there.
0
 
LVL 16

Accepted Solution

by:
ororiole earned 500 total points
ID: 21850066
Well, there are a couple of ways to fix that. Somewhere you instantiate your appcode objects right? and somewhere you call the methods on those objects. Pass them the Page object in the constructor if that works or just when you call a method: appcodeObject.MyMethod(Page, blah, blah); Then you have access to the viewstate.


0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
looking for an ASP.net report designer 4 41
pressing download button in c# 7 34
Get sourcecode path 14 46
Error building VS2105 solution from repository 1 35
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question