persist xml in class referenced in asp.net page

M

magister

hello I am putting together a web form which builds an xml file.

I have another class which is referenced in the asp.net page.
The first page load creates an instance of the class. In the class
are various methods which build up an xml file...ie create method
builds the
first root element, and other calls add elements and attributes to
this base root node.

The webpage has various buttons, dropdowns, and other controls which
when clicked on perform the various methods.

Now I could write the current XML to a filestore after each method in
my separate class file ie, Create root node, add elements, add
attributes, but I would rather persist an xmldocument object in the
class somehow.

However my asp.net page doesn't hold the properties of the first call
to the separate class into the second call. So if I instanciate my
class on the first page load, and don't recreate it on postback, if in
after CreateRoot() method called after the first button click, I call
an AddElement() method after another event, the xmldocument object
doesn't have its root node anymore.

Is there anyway a class can do this for an asp.net page, persist xml
between multiple postbacks, or is this by nature not possible due to
the fact that asp.net destroys all objects when it unloads???

Any clarification appreciated, I am attempting to build some
EnterpriseServices around the generation of Xml Template based
system....

Thanks,
yurps
 
P

Patrick Steele [MVP]

Is there anyway a class can do this for an asp.net page, persist xml
between multiple postbacks, or is this by nature not possible due to
the fact that asp.net destroys all objects when it unloads???

Look into the ViewState:

"Saving Web Forms Page Values Using View State"
http://tinyurl.com/2a8ns
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top