什么变量放在viewstate里都对本页有效。
解决方案 »
- 忏悔贴==》mbh0210 ,huming_h , xuenzhen123
- 常规网络错误。请检查您的网络文档
- 奇怪问题求救呀~~~~~
- 我在asp.net的一个类里写了Debug.Print(s),在哪看s的值?
- 树型目录树的一个小问题dv.Table = ds.Tables("tree") 报错!!
- sql2000客户端sa无法登陆?听说是身份验证的问题么?
- 问个水晶报表打印纸张格式的问题
- 中国挖掘机那加强?
- 一个文本框,有一个验证控件(判断是否为数字),还有一个textchanged事件,这是一个矛盾的东西,让我头疼~~
- 请问ASP。NET如何读取ORACLE数据库?
- 我发现在 C# 的类里面用全局变量 protect string test="test"; 可以用到该类对应的 .aspx 文件里面去。
- FIX:ASP.NET 中 .NET Data Provider for Oracle 的连接漏洞 (请使用ORACLE数据库的兄弟一定注意!)
private void Page_Load(object sender, System.EventArgs e)
{
chgcount=chgcount+1;
if(ViewState["chgcount"]!=null)
{
if((int)this.ViewState["chgcount"] > 2)
Response.Write("lock out");
}
else
ViewState["chgcount"]=0 ;
Response.Write(this.ViewState["chgcount"].ToString());
}页面刷新时候,chgcount仍然是0,我想在页面刷新时候可以加1
只有重新进来页面时候,chgcount才为零
{
chgcount=chgcount+1;
if(ViewState["chgcount"]!=null)
{
if((int)this.ViewState["chgcount"] > 2)
Response.Write("lock out");
}
else
{
ViewState["chgcount"]=0 ;
Response.Write(this.ViewState["chgcount"].ToString());
}}
{
chgcount=chgcount+1;------>>>>改为:chgcount=(int)ViewState["chgcount"]+1 试试
if(ViewState["chgcount"]!=null)
{
if((int)this.ViewState["chgcount"] > 2)
Response.Write("lock out");
}
else
ViewState["chgcount"]=0 ;
Response.Write(this.ViewState["chgcount"].ToString());
}GoodLuck!!
private void Page_Load(object sender, System.EventArgs e)
{
ViewState["chgcount"] = chgcount;
if(!Page.IsPostBack)
{
chgcount=(int)ViewState["chgcount"]+1; if(ViewState["chgcount"]!=null)
{
if(Convert.ToInt32(ViewState["chgcount"].ToString())>2)
Response.Write("lock out");
}
else
{
ViewState["chgcount"]=0 ;
Response.Write(this.ViewState["chgcount"].ToString());
} }
你的变量应该定义成static
如果只包含一个类,可以使用private声明