All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
增加网站流量方法之ASP.NET弹出窗口技术_[Asp.Net教程]
sql server取出内容中汉字,数字,字母_[SQL Server教程]
DotNet中用到的加密算法总结_.net资料_编程技术
Silverlight,2(beta1)数据操作(2)——使用ASP.NET,Web,Service_[Asp.Net教程]
知识库:.NET应用程序开发标准化_.net资料_编程技术
PHP和AJAX打造高级RSS聚合器_[PHP教程]
asp.net新闻标题后加new图片_[Asp.Net教程]
ASP.NET通过IE直接打印_[Asp.Net教程]
MS SQL 2005的新功能创建数据库快照_[SQL Server教程]
Sqlserver数据库安全配置九大措施_[SQL,Server教程]
Reading number is top 10 pictures
无题
来几张有特色的图片
再来随便发几张
From China fortress sora aoi1
大人物的礼物
So beauty, will let you spray blood9
Soong ching ling's former residence2
Sora aoi on twitter4
The money of more than 100 countries and regions10
粉红蕾丝的美女
Download software ranking
Eclipse 4.2.2 For Win32
Boxer vs Yellow3
Tram sex maniac 2 (H) rar bag13
ASP.NET.2.0.XML.高级编程(第3版)
株洲本地在线棋牌游戏
尖东毒玫瑰A
WebService在.NET中的实战应用教学视频 → 第2集
The Bermuda triangle1
Boxer's Top ten classic battle9
天龙八部最新服务端
delv published in(发表于) 2014/1/27 6:45:19 Edit(编辑)
.NET内置对象之Application对象_[Asp.Net教程]

.NET内置对象之Application对象_[Asp.Net教程]

.NET内置对象之Application对象_[Asp.Net教程]

Application对象


Application对象是HttpApplicationState类的一个实例,它可以产生一个所有Web应用程序都可以存取的变量,这个变量的可以存取范围涵盖全部使用者,也就是说只要正在使用这个网页的程序都可以存取这个变量。


新建一个网站,包括两个网页,代码如下:


1、Index.aspx代码:


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Index.aspx.cs" Inherits="Index" %>





无标题页













用户名:












密 &nbsp;&nbsp; 码:












onClick="Button1_Click" />











Index.aspx.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 Index : System.Web.UI.Page


{


string strInfo;


protected void Page_Load(object sender, EventArgs e)


{



}


protected void Button1_Click(object sender, EventArgs e)


{


Application["Info"] = TextBox1.Text;


strInfo = Application["Info"].ToString();


if (TextBox1.Text == "admin" && TextBox2.Text == "admin")


{


Session["name"] = TextBox1.Text;


Response.Redirect("Default.aspx?Info=" + strInfo + "");//地址栏的传值


}


}


}


2、Default.aspx代码:


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>







无标题页


























&nbsp;


onClick="Button2_Click" />











Default.aspx.cs代码:


using System;


using System.Data;


using System.Configuration;


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 _Default : System.Web.UI.Page


{


protected void Page_Load(object sender, EventArgs e)


{


Label1.Text = Session["name"].ToString();


/*对象的增加


Application.Add("App1", "Value1");


Application.Add("App2", "Value2");


Application.Add("App3", "Value3");


Response.Write("Application对象的使用");


Response.Write("
");


for (int i = 0; i < Application.Count; i++)


{


Response.Write("变量名:" + Application.GetKey(i));


Response.Write(",值:" + Application[i] + "

");


Response.Write("
");


}*/


}


protected void Button2_Click(object sender, EventArgs e)


{


Application["content"] = TextBox1.Text;


TextBox2.Text = TextBox2.Text + "\n" + Label1.Text + "说:" + Application["content"].ToString();


}


}









添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.