session传值取值
protected void Page_Load(object sender, EventArgs e)
{
//判断session是否为空
if (Session["user"]!=null)
{
//UserInfo us = new UserInfo(string username,string pwd, string email);
UserInfo us = (UserInfo)Session["user"];
this.username.Text = us.Username;
this.pwd.Text = us.Pwd;
// string s = (string)Session["User"];
Response.Write(" <script>alert('您已经注册登陆了,即将返回首页!');</script>");
Response.Write(" <script>alert('跳转中');window.location.href='index.aspx';</script>");
}
else
{
Session["user"] = null;
}
}
protected void Button1_Click1(object sender, EventArgs e)
{
string usernams = this.username.Text;
string pwd = this.username.Text;
if (Session["user"]!=null)
{
UserInfo us=(UserInfo)Session["user"];
//假如session为空,证明没有注册,对于这种人,密码账号你就瞎写,让他注册才能打开
if (us.Username==usernams&&us.Pwd==pwd)
{
Response.Write(" <script>alert('跳转中');window.location.href='index.aspx';</script>");
}
else
{
Response.Write("<script>aleat('密码错误')</script>");
}
}
else
{
if ( usernams!="用户名你猜不到" && pwd!="密码你猜不到")
{
Response.Write("<script>alert('密码错误')</script>");
}
else
{
Response.Write(" <script>alert('跳转中');window.location.href='index.aspx';</script>");
}
}
// UserInfo us = new UserInfo
// {
// Username = (string)Session["User"]
// };
// Response.Write(" <script>alert('" +us. Username + "');</script>");
//}
//string ua=Session["user"];
//UserInfo us = new UserInfo();
//string s = (string)Session["User"] ;
// Response.Write(us.Pwd);
}
}
------------------登陆界面------------

protected void Button1_Click(object sender, EventArgs e)
{
UserInfo user = new UserInfo();
user.Username = this.username.Text;
user.Pwd = this.pwd.Text;
user.Email = this.email.Text;
Session["user"] = user;
// Response.Write(user.Pwd);
Response.Write(" <script>alert('注册成功,跳转中');window.location.href='index.aspx';</script>");
}
-----------注册-----------------------
//由于session的数据放在服务器,不能大量占用资源,创建个类
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
/// <summary>
/// UserInfo 的摘要说明
/// </summary>
public class UserInfo
{
public UserInfo()
{
}
/// <summary>
/// 创建用户名,密码,邮箱变量,存数据,封装变量,构造函数
/// </summary>
private string username;
public string Username
{
get { return username; }
set { username = value; }
}
private string pwd;
public string Pwd
{
get { return pwd; }
set { pwd = value; }
}
private string email;
public string Email
{
get { return email; }
set { email = value; }
}
public UserInfo(string username, string pwd, string Email) {
Username = username;
Pwd = pwd;
Email = email;
}
}
END
session传值取值的更多相关文章
- Mvc4_传值取值应用
Mvc路由运行机制: 首先,Web 浏览器向服务器发送一条URL 请求,如http://HostName/ControllerName/ActionName/Parameters. 其次,请求被A ...
- React使用DVA本地state传值取值
React使用DVA本地state传值取值 最近在用Ant Pro 做一个后台系统,在使用中发现Antd Pro使用DVA来实现redux+sagas+router一系列的功能,比传统方式要方便快捷的 ...
- 微信小程序 传值取值的方法总结
微信小程序 传值取值的几种方法总结 列表index下标取值 页面传值 form表单取值 1. 列表index下标取值 实现方式是:data-index="{{index}}"挖坑及 ...
- 【2017-05-21】WebForm跨页面传值取值、C#服务端跳转页面、 Button的OnClientClick属性、Js中getAttribute和超链接点击弹出警示框。
一.跨页面传值和取值: 1.QueryString - url传值,地址传值 优缺点:不占用服务器内存:保密性差,传递长度有限. 通过跳转页面路径进行传值,方式: href="地址?key= ...
- WebForm跨页面传值取值、C#服务端跳转页面、 Button的OnClientClick属性和超链接点击弹出警示框
一.跨页面传值和取值: 1.QueryString - url传值,地址传值 优缺点:不占用服务器内存:保密性差,传递长度有限. 通过跳转页面路径进行传值方式: href="地址?key=v ...
- 微信小程序传值取值的几种方法
一,列表index下的取值 实现方式是:data-index="{{index}}"挖坑及e.currentTarget.dataset.index来填坑即可 1.1生成值 < ...
- EL表达式从request和session中取值
在Action中保存登录的基本信息:request.getSession().setAttribute("adminid", str); 在JSP页面中:${sessionScop ...
- Spring MVC 常用注解 和session界面渲染取值
@RequestParams name 修饰当前形参的属性 value 和name属性一样 也是修饰当前属性 defaultValue 给属性设置一个默认值 默认属性 required 必备属性 1. ...
- ASP.NET GridView HyperLinkField传值和取值【转】
来源:http://www.cnblogs.com/junjie94wan/archive/2011/08/17/2143623.html 经常做Winform程序,好久没有做WEB都有些生疏了,Gr ...
随机推荐
- 找回Firefox4的状态栏!Status-4-Evar扩展
Status-4-Evar这个扩展能让Firefox4故意移除的状态栏给找回来!官方下载地址为:https://addons.mozilla.org/zh-CN/firefox/addon/23528 ...
- Ocelot 配置参数
Downstream是下游服务配置 UpStream是上游服务配置 Aggregates 服务聚合配置 ServiceName, LoadBalancer, UseServiceDiscovery 配 ...
- Jmeter综合运用 之 接口测试
Jmeter用的最多的就是做接口和性能测试了,着实比较好用,今天给大家分享下如何利用Jmeter做接口测试. 在做接口测试之前,我们起码需要了解: 1.接口涉及的业务 2.接口的基本信息:访问地址.传 ...
- VB6_小林的气象类模块
前言. [如果使用过程有什么问题可以QQ或邮箱联系我. 1919988942 | w2638301509@gmail.com] ___________________________________ ...
- K8s架构详解
每个微服务通过 Docker 进行发布,随着业务的发展,系统中遍布着各种各样的容器.于是,容器的资源调度,部署运行,扩容缩容就是我们要面临的问题. 基于 Kubernetes 作为容器集群的管理平台被 ...
- Django边角料
模型层表名自定义: class Record(models.Model): content=models.CharField(max_length=32,db_column='record_conte ...
- 顺序表的基本操作【c语言】【创建、插入、删除、输出】
作为数据结构初学者,上课时对一些知识点掌握得不是很透彻,所以利用课余时间通过微博平台总结所学知识,加深对知识的见解,记录学习历程便于后需要时参考. #include<stdio.h> #i ...
- 执行sudo命令时command not found的解决办法
问题的原因: 在编译sudo包的时候默认开启了- -with-secure-path选项. 方法1: sudo vim /etc/sudoers,并在文件内增加这么一行:Defaults secure ...
- 《MIT 6.828 Lab 1 Exercise 7》实验报告
本实验链接:mit 6.828 lab1 Exercise 7. 题目 Exercise 7. Use QEMU and GDB to trace into the JOS kernel and st ...
- *#【Python】【基础知识】【模块】【datetime】【使用datetime模块 】
datetime模块 的介绍: 用于调取时间.日期 datetime包含的 方法: >>> dir(datetime) ['MAXYEAR', 'MINYEAR', '__built ...