本文整理匯總了VB.NET中System.Web.UI.Page.EnableViewState屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET Page.EnableViewState屬性的具體用法?VB.NET Page.EnableViewState怎麽用?VB.NET Page.EnableViewState使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Web.UI.Page
的用法示例。
在下文中一共展示了Page.EnableViewState屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: WebPage
Public Class WebPage
Inherits System.Web.UI.Page
Private myFormObj As MyForm
Private label1 As Label
Private label2 As Label
Private textBoxObj As TextBox
Private buttonObj As Button
Public Sub New()
AddHandler Page.Init, AddressOf Page_Init
End Sub
Private Sub Page_Load(sender As Object, e As System.EventArgs)
' Comment the following line to maintain page view state.
Page.EnableViewState = false
myFormObj.Method = "post"
Controls.Add(myFormObj)
textBoxObj.Text = "Welcome to .NET"
label1.Text = "Enter a name"
buttonObj.Text = "ClickMe"
AddHandler buttonObj.Click, AddressOf Button_Click
myFormObj.Controls.Add(label1)
myFormObj.Controls.Add(textBoxObj)
myFormObj.Controls.Add(buttonObj)
myFormObj.Controls.Add(label2)
End Sub
Private Sub Button_Click(sender As Object, e As EventArgs)
Dim temp As [String] = "<br>Name is " + textBoxObj.Text + "<br>"
temp += "Saved content of previous page is " + CType(ViewState("name"), String)
label2.Text = temp
End Sub
Protected Overrides Sub LoadViewState(viewState As Object)
If Not (viewState Is Nothing) Then
MyBase.LoadViewState(viewState)
End If
End Sub
Protected Overrides Function SaveViewState() As Object
ViewState("name") = textBoxObj.Text
Return MyBase.SaveViewState()
End Function 'SaveViewState
Private Sub Page_Init(sender As Object, e As EventArgs)
AddHandler Me.Load, AddressOf Me.Page_Load
myFormObj = New MyForm()
label1 = New Label()
label2 = New Label()
textBoxObj = New TextBox()
buttonObj = New Button()
End Sub
End Class