zoukankan
html css js c++ java
Application、Session、Server 状态管理
Application 可以存放任何对象,包括数组.
以下是Application 存放数组的例子
前台页面代码:
<%
@ Page Language
=
"
C#
"
AutoEventWireup
=
"
true
"
CodeFile
=
"
Application.aspx.cs
"
Inherits
=
"
ApplicationSessionServer_Application
"
%>
<!
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
>
=============================<
br
/>
Application 可以存放任何对象,包括数组.
<
br
/>
以下是Application 存放数组的例子
<
br
/>
<
br
/>
<
asp:Button ID
=
"
Button1
"
runat
=
"
server
"
OnClick
=
"
Button1_Click
"
Text
=
"
存储数组
"
/>
<
asp:Button ID
=
"
Button2
"
runat
=
"
server
"
OnClick
=
"
Button2_Click
"
Text
=
"
读取数组
"
/><
br
/>
<
br
/>
<
asp:ListBox ID
=
"
ListBox1
"
runat
=
"
server
"
Height
=
"
145px
"
Width
=
"
158px
"
></
asp:ListBox
></
div
>
</
form
>
</
body
>
</
html
>
后台代码CS:
using
System;
using
System.Data;
using
System.Configuration;
using
System.Collections;
using
System.Web;
using
System.Web.Security;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Web.UI.WebControls.WebParts;
using
System.Web.UI.HtmlControls;
public
partial
class
ApplicationSessionServer_Application : System.Web.UI.Page
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
}
protected
void
Button1_Click(
object
sender, EventArgs e)
{
string
[] a
=
new
string
[
4
];
a[
0
]
=
"
程序员
"
;
a[
1
]
=
"
教师
"
;
a[
2
]
=
"
工人
"
;
a[
3
]
=
"
司机
"
;
Application.Add(
"
a
"
,a);
//
利用 Application 的 Add方法,存储Application
}
protected
void
Button2_Click(
object
sender, EventArgs e)
{
string
[] b
=
(
string
[])Application[
"
a
"
];
//
强制类型转换.对象转换为数组,然后在 ListBox 中显示出来.
for
(
int
i
=
0
; i
<
b.Length;i
++
)
{
this
.ListBox1.Items.Add(b[i]); //利用ListBox 控件显示出来。
}
}
}
查看全文
相关阅读:
学习:GridView中asp:BoundField的Visible=false时,无法取到这个字段的值
C#读、写、删除注册表
ERROR [IM002] [Microsoft][ODBC 驱动程序管理器] 未发现数据源名称并且未指定默认驱动程序
Gridview隐藏列的取值问题
SQL 2005导入EXCEL
GridView使用LinkButton和Button两种方式的删除确认
(转)ASP.Net的AccessDataSource设置错误"未将对象引用设置到对象的实例"的解决方案
给GridView文本加上边框
(转)从客户端中检测到有潜在危险的 Request.Form 值
(转)Asp.net中的ServerVariables集合
原文地址:https://www.cnblogs.com/gfwei/p/533056.html
最新文章
所有Loading效果
关于IE6下fixed元素闪动的解决
vs08+ie8开发遇到的问题
SQL冗余字段的策略和管理
消除数据库JS入侵的脚本
Windows 远程桌面不能连接解决办法zt
Python企业应用的优缺点(zt)
iisExpress的设置
数据绑定到分页的快速开发最佳实践
sql命令行添加一个登陆给某数据库,并给予指定角色(备忘)
热门文章
dataset绑定翻页和泛型+实体类绑定翻页的性能比较
python应用领域介绍 (zt)
Towards secure and dependable softwaredefined networks
A Survey of Security in Software Defined Networks
基于强化学习的服务链映射算法
【培训实验记录】锐捷SDN交换机和控制器部署
《图解OpenFlow》第一章:OpenFlow概要
《图解OpenFlow》第二章:OpenFlow1.0的机制
SoftwareDefined Networking:A comprehensive Survey
开始写博客了
Copyright © 2011-2022 走看看