How to call a class

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2007
Posts: 2
Reputation: Danish woman is an unknown quantity at this point 
Solved Threads: 0
Danish woman Danish woman is offline Offline
Newbie Poster

How to call a class

 
0
  #1
Aug 25th, 2007
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 :
  1. public class PersistViewStateToFileSystem : inherits Page
  2.  
  3. public ViewStateFilePath = server.MapPath("/album/myViewstate.txt")
  4.  
  5. Protected Overloads Overrides Sub SavePageStateToPersistenceMedium(ByVal viewState As Object)
  6. ' serialize the view state into a base-64 encoded string
  7. Dim los as LosFormatter= new LosFormatter()
  8. Dim writer as StringWriter= new StringWriter()
  9. los.Serialize(writer, viewState)
  10. ' save the string to disk
  11. Dim sw as new StreamWriter(ViewStateFilePath, false)
  12. sw.Write(writer.ToString())
  13. sw.Close()
  14. end sub
  15.  
  16.  
  17. Protected Overloads Overrides Function LoadPageStateFromPersistenceMedium() As Object
  18. ' determine the file to access
  19. if NOT File.Exists(ViewStateFilePath)
  20. return nothing
  21. else
  22. ' open the file
  23. Dim sr as StreamReader= File.OpenText(ViewStateFilePath)
  24. Dim viewStateString as string = sr.ReadToEnd()
  25. sr.Close()
  26. ' deserialize the string
  27. Dim los as LosFormatter = new LosFormatter()
  28. return los.Deserialize(viewStateString)
  29. end if
  30. end Function
  31. end class

The code is in my aspx page.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC