<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
File: Default.aspx.vb
Partial Class _Default
Inherits System.Web.UI.Page
<Serializable()> Class Person
Public first As String = "first"
Public last As String = "last"
Public blog As String = "http://www.java2java.com"
End Class
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim people(500) As Person
For i As Integer = 0 To people.Length - 1 Step 1
people(i) = New Person
Next
ViewState("Folks") = people
End Sub
Dim _pageGuid As String = Nothing
Public Property PageGuid() As String
Get
'Do we have it already? Check the Form, this could be a post back
If (_pageGuid = Nothing) Then
_pageGuid = Me.Request.Form("__VIEWSTATE_KEY")
End If
'No? We'll need one soon.
If (_pageGuid = Nothing) Then
_pageGuid = Guid.NewGuid.ToString
End If
Return _pageGuid
End Get
Set(ByVal value As String)
_pageGuid = value
End Set
End Property
Protected Overrides Function LoadPageStateFromPersistenceMedium() As Object
Return Session(Me.PageGuid)
End Function
Protected Overrides Sub SavePageStateToPersistenceMedium(ByVal viewState As Object)
RegisterHiddenField("__VIEWSTATE_KEY", Me.PageGuid)
Session(Me.PageGuid) = viewState
End Sub
End Class
|