944,177 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 9085
  • VB.NET RSS
Aug 25th, 2007
0

How to call a class

Expand Post »
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 :
VB.NET Syntax (Toggle Plain Text)
  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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Danish woman is offline Offline
2 posts
since Aug 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: SQL express on a remote machine
Next Thread in VB.NET Forum Timeline: How to create an instlallation file in VB.net??





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC