473,406 Members | 2,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How do I retain data after the page has been reloaded?

I am trying to keep from reloading my XmlDocument every time my page reloads.
To do this I am using ViewState.

System.Xml.XmlDocument myDataXmlDoc = new System.Xml.XmlDocument();
myDataXmlDoc.Load("myData.xml");
ViewState["myDataXmlDoc"] = myDataXmlDoc;

When I do this I get the following error:

Type 'System.Xml.XmlDocument' in Assembly 'System.Xml, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as
serializable.

Please let me know of anything I can do.

Nov 7 '08 #1
6 2589
I think, you need to reload xml document again. you need to store xml
document as string in viewstate, and then load it again.
In fact sometimes xml string are used for loading different kind of objects
( like dataset).
--
Vinay Khaitan
[Windows Forms Layout Control]
http://www.smart-components.com/
----------------------------------------------------------------
"Flyguy" <fl****@nospam.nospamwrote in message
news:A8**********************************@microsof t.com...
>I am trying to keep from reloading my XmlDocument every time my page
reloads.
To do this I am using ViewState.

System.Xml.XmlDocument myDataXmlDoc = new System.Xml.XmlDocument();
myDataXmlDoc.Load("myData.xml");
ViewState["myDataXmlDoc"] = myDataXmlDoc;

When I do this I get the following error:

Type 'System.Xml.XmlDocument' in Assembly 'System.Xml, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as
serializable.

Please let me know of anything I can do.

Nov 7 '08 #2
"Flyguy" <fl****@nospam.nospamwrote in message
news:A8**********************************@microsof t.com...
Please let me know of anything I can do.
ViewState["myDataXmlDoc"] = myDataXmlDoc.OuterXml;

Then, when you need it again:

System.Xml.XmlDocument myDataXmlDoc = new System.Xml.XmlDocument();
myDataXmlDoc.Load(ViewState["myDataXmlDoc"].ToString());
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Nov 7 '08 #3
unless you xml is really small (couple hundred bytes), this is a very poor
design. viewstate is shipped to the browser, then shipped back using up
brandwidth, and making your site slow.

-- bruce (sqlwork.com)
"Mark Rae [MVP]" wrote:
"Flyguy" <fl****@nospam.nospamwrote in message
news:A8**********************************@microsof t.com...
Please let me know of anything I can do.

ViewState["myDataXmlDoc"] = myDataXmlDoc.OuterXml;

Then, when you need it again:

System.Xml.XmlDocument myDataXmlDoc = new System.Xml.XmlDocument();
myDataXmlDoc.Load(ViewState["myDataXmlDoc"].ToString());
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Nov 7 '08 #4
"bruce barker" <br*********@discussions.microsoft.comwrote in message
news:E7**********************************@microsof t.com...
Please let me know of anything I can do.

ViewState["myDataXmlDoc"] = myDataXmlDoc.OuterXml;

Then, when you need it again:

System.Xml.XmlDocument myDataXmlDoc = new System.Xml.XmlDocument();
myDataXmlDoc.Load(ViewState["myDataXmlDoc"].ToString());

Unless you xml is really small (a couple of hundred bytes), this is a very
poor
design. Viewstate is shipped to the browser, then shipped back using up
bandwidth, and making your site slow.
Yes, I would agree with you. I try to use ViewState as sparingly as possible
for precisely this reason.

I should have mentioned this...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Nov 7 '08 #5
You are right that viewstate should be used for very less amount of data
only. And also, XML loading time can be higher for large xmls. But you
really have very little choice. You can use Session variable to store it
too. But that would amount to using more memory per session.
You can also use SQL server as state server to reduce memory requirements.
Or you can write custom code to store this loaded xml to sql server?

--
Vinay Khaitan
[Windows Forms Layout Control]
http://www.smart-components.com/
----------------------------------------------------------------
"bruce barker" <br*********@discussions.microsoft.comwrote in message
news:E7**********************************@microsof t.com...
unless you xml is really small (couple hundred bytes), this is a very poor
design. viewstate is shipped to the browser, then shipped back using up
brandwidth, and making your site slow.

-- bruce (sqlwork.com)
"Mark Rae [MVP]" wrote:
>"Flyguy" <fl****@nospam.nospamwrote in message
news:A8**********************************@microso ft.com...
Please let me know of anything I can do.

ViewState["myDataXmlDoc"] = myDataXmlDoc.OuterXml;

Then, when you need it again:

System.Xml.XmlDocument myDataXmlDoc = new System.Xml.XmlDocument();
myDataXmlDoc.Load(ViewState["myDataXmlDoc"].ToString());
--
Mark Rae
ASP.NET MVP
http://www.markrae.net


Nov 7 '08 #6
Hi,

I see some suggestions have been provided by MVPs. Have you got the
expected answer? Do you have further questions? Please don't hesitate to
let me know if you need further assistance. I'll try my best to followup.

Regards,
Allen Chen
Microsoft Online Community Support
--------------------
| Thread-Topic: How do I retain data after the page has been reloaded?
| thread-index: AclA590GxxDmPmYSQL+JidLTq/9hJg==
| From: =?Utf-8?B?Rmx5Z3V5?= <fl****@nospam.nospam>
| Subject: How do I retain data after the page has been reloaded?
| Date: Fri, 7 Nov 2008 06:48:14 -0800
| Lines: 15
| Message-ID: <A8**********************************@microsoft.co m>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.3119
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Path: TK2MSFTNGHUB02.phx.gbl
| Xref: TK2MSFTNGHUB02.phx.gbl
microsoft.public.dotnet.framework.aspnet:79432
| NNTP-Posting-Host: tk2msftsbfm01.phx.gbl 10.40.244.148
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| I am trying to keep from reloading my XmlDocument every time my page
reloads.
| To do this I am using ViewState.
|
| System.Xml.XmlDocument myDataXmlDoc = new System.Xml.XmlDocument();
| myDataXmlDoc.Load("myData.xml");
| ViewState["myDataXmlDoc"] = myDataXmlDoc;
|
| When I do this I get the following error:
|
| Type 'System.Xml.XmlDocument' in Assembly 'System.Xml, Version=2.0.0.0,
| Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as
| serializable.
|
| Please let me know of anything I can do.
|
|

Nov 13 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Vic Spainhower | last post by:
Hello, I am new to php and mySQL so this is probably something very basic that I'm missing. Basically, on the page I have 2 combo boxes but 1 of them is not getting the value passed when the...
4
by: crhaynes | last post by:
I'm having trouble with my CSS. My links are black, my hover is orange and my active link is red. When I select a link it turns red but i does not retain that color when the selected page loads. ...
1
by: krian | last post by:
Hi, I need a help from anybody. My problem is here I wrote two WebApplication in ASP.net Using C#. The name of the applications are (Journal.aspx and Payment.aspx). These Two pages have DataGrids...
2
by: Shapper | last post by:
Hello, I have in my page a few Asp:ImageButtons and a few Asp:Panels. When a button is pressed the function Show_Hide is called and a panel visibility is set to true or false. The problem...
4
by: Matt Jensen | last post by:
Howdy all Been searching and can't find a good answer to my problem. I've got a usercontrol 'banner' at the top of my page, and when the selection in the dropdown list changes I want the "host"...
15
by: tmax | last post by:
PHP Pros: I have a simple html form that submits data to a php script, which processes it, and then redisplays the same page, but with a "thank you" message in place of the html form. This is...
4
by: sydney.luu | last post by:
Hello All, I am programmatically building a table on my web page with one row and two columns. The first column contains a web server checkbox dynamically created and the second column simply...
4
by: pankajsingh5k | last post by:
Hi guys, These question is for all the experts... Please help me before my brain explodes The problem is again with the formview control.. I have a formview and i have to use it that...
5
by: raamay | last post by:
i have a form via which new users can register their information along with their Resume. Now when input validation is done, if there is some errors, then the page is reloaded with the users...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.