asp.net代码练习 work007 ViewState[]的使用
发布日期:2021-05-06 21:17:37 浏览次数:17 分类:精选文章

本文共 1173 字,大约阅读时间需要 3 分钟。

webform1.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="work007.WebForm1" %>
设置
获取

webform1.aspx.cs

using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;namespace work007{    public partial class WebForm1 : System.Web.UI.Page    {        protected void Page_Load(object sender, EventArgs e)        {        }        protected void btnSet_Click(object sender, EventArgs e)        {            ViewState["content"] = txtSource.Text.Trim();        }        protected void btnGet_Click(object sender, EventArgs e)        {            if (ViewState["content"] != null)            {                txtResult.Text = (string)ViewState["content"];            }            else            {                txtResult.Text = string.Empty;            }        }    }}

 

上一篇:asp.net代码练习 work008 <%%>和<%=%>的使用,输出九九乘法表
下一篇:asp.net代码练习 work006 Application[]和Session[]的区别

发表评论

最新留言

不错!
[***.144.177.141]2025年03月21日 04时21分13秒