gpt4 book ai didi

asp.net - vb.net View 状态与公共(public)变量

转载 作者:行者123 更新时间:2023-12-02 22:12:34 24 4
gpt4 key购买 nike

这是 aspx 页面的一些隐藏代码。我不确定我是否应该使用公共(public)变量或 viewState

Partial Class madeUpName
Inherits System.Web.UI.Page
Public vin As String = ""
Public stk As String = ""

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'inside of here i use the variables
end sub

Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
'inside of here I also use the same variables
end sub

我应该在我的页面类中使用 viewState 变量还是公共(public)变量?看起来他们都取得了同样的成就。

最佳答案

如果您希望值在回发之间保持不变,请使用 ViewState

如果值只需要在页面的生命周期内存在,那么常规变量就可以了。

关于asp.net - vb.net View 状态与公共(public)变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15009085/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com