四虎精品视频-四虎精品成人免费网站-四虎黄色网-四虎国产视频-国产免费91-国产蜜臀97一区二区三区

ASP.NET內置對象之Application對象

新建一個網站,包括兩個網頁,代碼如下:
1、Index.ASPx代碼: 
復制代碼 代碼如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Index.ASPx.cs" Inherits="Index" %>
<!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>
<table style="width: 300px; height: 100px">
<tr>
<td style="width: 100px">
用戶名:</td>
<td style="width: 246px">
<ASP:TextBox ID="TextBox1" runat="server"></ASP:TextBox></td>
</tr>
<tr>
<td style="width: 100px">
密    碼:</td>
<td style="width: 246px">
<ASP:TextBox ID="TextBox2" runat="server" TextMode="Password"></ASP:TextBox></td>
</tr>
<tr>
<td style="text-align: center;" colspan="2">
<ASP:Button ID="Button1" runat="server" Text="登錄" OnClick="Button1_Click" /></td>
</tr>
</table>
</div>
</form>
</body>
</html>

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" %>
<!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>
<table style="width: 500px; height: 323px">
<tr>
<td colspan="2">
<ASP:TextBox ID="TextBox2" runat="server" Height="314px" Width="497px" TextMode="MultiLine"></ASP:TextBox></td>
</tr>
<tr>
<td>
<ASP:Label ID="Label1" runat="server" Text="Label"></ASP:Label>
<ASP:TextBox ID="TextBox1" runat="server" Width="390px"></ASP:TextBox></td>
<td>
 
<ASP:Button ID="Button2" runat="server" Text="發送" OnClick="Button2_Click" /></td>
</tr>
</table>
</div>
</form>
</body>
</html>
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("<br>");
for (int i = 0; i < Application.Count; i++)
{
Response.Write("變量名:" + Application.GetKey(i));
Response.Write(",值:" + Application[i] + "<p>");
Response.Write("<br>");
}*/
}
protected void Button2_Click(object sender, EventArgs e)
{
Application["content"] = TextBox1.Text;
TextBox2.Text = TextBox2.Text + "/n" + Label1.Text + "說:" + Application["content"].ToString();
}
}

AspNet技術ASP.NET內置對象之Application對象,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 消防给水及消火栓系统技术规范| 我和我的祖国钢琴谱完整版| 电影《ol3》完整版在线观看| 狼来了ppt免费下载| 成人生活| 国家征收土地多少钱一亩| 媳妇的全盛时代| 李赫洙| 北风那个吹全集免费观看| 王渝萱的电影| 百字明咒标准读诵慢念| 快乐到家| cctv16直播| 10000个常用人名| 李修蒙出生年月| 李雪琴个人资料及简历| 房东小姐| 罗中立的《父亲》详案| 赵冬苓代表作品有哪些| 血色天劫| 尹雪喜最惊艳的十部电视剧| 红日图片| 送老师锦旗写什么最好| 母亲とが话しています免费| 美国伦理女兵1| 男同性恋者| 佐藤亚璃纱| 美国舞男| 怎么剪福字简单方法视频| 搜狐首页网| 陈若仪个人简历资料| 褚阳| 好3| 花守由美里| 龟兔赛跑的故事视频| 即将到来1983年美国电影| 尤勇智的个人资料简介| 迷失之城剧情介绍| 就爱小姐姐| 都市频道在线直播| 妻子出轨|