在网站中使用Session的简单例子
2010-06-23 17:32
281 查看
前台放两个Button 一个是提交,一个是查询
后台:
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)
{
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
string name = this.TextBox1.Text;
this.Session["Username"] =name;
}
protected void LinkButton2_Click(object sender, EventArgs e)
{
this.Label1.Text = this.Session["Username"] as string;
}
}
后台:
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)
{
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
string name = this.TextBox1.Text;
this.Session["Username"] =name;
}
protected void LinkButton2_Click(object sender, EventArgs e)
{
this.Label1.Text = this.Session["Username"] as string;
}
}
相关文章推荐
- 在网站中使用Cookie的简单例子
- CInternetSession的简单使用例子
- 一个简单的HTTP通讯的例子,使用了CInternetSession,CHttpConnection,CHttpFile三个类。
- 一个简单的HTTP通讯的例子,使用了CInternetSession,CHttpConnection,CHttpFile三个类
- 如何使用epoll? 一个C语言的简单例子 - asdfjkl210 - ITeye技术网站
- CInternetSession的简单使用例子
- 如何使用epoll? 一个C语言的简单例子 - asdfjkl210 - ITeye技术网站
- SAP ABAP/4学习--学习使用OO在ABAP中.简单入门概念.用个例子来说明
- 玩转web之servlet(六)---session介绍及简单使用(登录验证中保存信息)
- 使用AJAX的简单小例子
- 如何使用Oracle存储过程的一个简单例子
- 使用jmeter进行接口压力测试的一个简单例子
- angularjs ngRoute的使用简单例子
- 使用smarty 缓存的简单例子
- 使用ParamQuery制作报表的例子(来自ParamQuery网站)
- 使用 CXF 做 webservice 简单例子
- objc_runtime使用方法的几个简单例子(转)
- FragmentTabHost的简单使用tab例子
- android framelayout的简单使用例子
- VC tab control 使用简单例子