zoukankan      html  css  js  c++  java
  • ViewState 视图状态对象实例

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DemoViewState.aspx.cs" Inherits="WebApplication1.DemoViewState" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        
            <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="增长" />
            <br />
            <br />
            <asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="加1" />
        
        </div>
        </form>
    </body>
    </html>
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    namespace WebApplication1
    {
        public partial class DemoViewState : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
    
            }
            public int i = 0;
            protected void Button1_Click(object sender, EventArgs e)
            { 
                i++;
                Response.Write(i); 
            }
    
            protected void Button2_Click(object sender, EventArgs e)
            {
                //ViewState 视图状态对象,它的数据是存在在页面的那个隐藏域
                if (ViewState["count"] == null)
                {
                    ViewState["count"] = 10;
                }
                else
                {
                    int x = Convert.ToInt32(ViewState["count"]);
                    x++;
                    ViewState["count"] = x;
                }
                Response.Write(ViewState["count"]);
            }
        }
    }
  • 相关阅读:
    visio 2019 激活方法
    sftp 多用户安装与配置
    CentOS configuration uses the SFTP server
    esxi命令行强行关闭虚拟机
    esxi 版本升级命令
    存储分析 开源重复数据删除技术崭露头角
    最简单-转换MBR为GPT
    CentOS 7 搭建本地YUM仓库,并定期同步阿里云源
    uml建模工具介绍
    C/C++中extern关键字详解
  • 原文地址:https://www.cnblogs.com/xiaz/p/5242512.html
Copyright © 2011-2022 走看看