Danish woman 0 Newbie Poster

I have worked with asp.net for about two month and have not worked with class yet.
I have a form with 10 usercontrols who contains dropdownlists, checkboxes, textboxes and more. My client have to make a dynamic requestform to send out to his members.
This part is working fine.
After the form is sent, I want to save the viewstate in a file, so that the client can access it anytime edit it.

I found the code for saving and loading the viewstate. It is in a class.

Now I don't know how to call the class in the page_load() so that the viewstate is saved and loaded.

This is the class :

public class PersistViewStateToFileSystem : inherits Page

public ViewStateFilePath = server.MapPath("/album/myViewstate.txt")

      Protected Overloads Overrides Sub SavePageStateToPersistenceMedium(ByVal viewState As Object)
     ' serialize the view state into a base-64 encoded string
      Dim los as LosFormatter= new LosFormatter()
      Dim writer as StringWriter= new StringWriter()
      los.Serialize(writer, viewState)
      ' save the string to disk
      Dim sw as new StreamWriter(ViewStateFilePath, false)
      sw.Write(writer.ToString())
      sw.Close()
   end sub


        Protected Overloads Overrides Function LoadPageStateFromPersistenceMedium() As Object
     '   determine the file to access
      if NOT File.Exists(ViewStateFilePath)
         return nothing
      else
         ' open the file
         Dim sr as StreamReader= File.OpenText(ViewStateFilePath)
         Dim viewStateString as string = sr.ReadToEnd()
         sr.Close()
         ' deserialize the string
         Dim los as LosFormatter = new LosFormatter()
         return los.Deserialize(viewStateString)
      end if
 end Function 
end class

The code is in my aspx page.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.