本文介绍了刷新网页后,限制重置在类中声明的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello!!!

I have declared a variable under a class of my VB.NET 

<pre lang="vb">
Partial Public Class _Default
    Inherits System.Web.UI.Page
    Private flg_edit As Integer


每当刷新网页时,即使我在后续代码中将其设置为1,该变量(flg_edit)也会重置为0.

我想在整个网页中使用此变量.
我该怎么办?

谢谢!!!

Ernest.


Whenever the webpage is refreshed this variable (flg_edit) is reset to 0 even if I had set it to 1 in the subsiquent code.

I want to use this variable throughout the webpage.
How do I do that?

Thanks!!!

Ernest.

推荐答案

If ViewState["EditNum"] Is Nothing Then
  flg_edit = 1
Else
  flg_edit = CType(ViewState["EditName"], Int32)
End If

并且您以如下方式保存ViewState:

And you save your ViewState like this:

ViewState["EditNum"] = flg_edit


Dim Shared flg_edit As Integer



这篇关于刷新网页后,限制重置在类中声明的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 12:21