本文整理汇总了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