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 ...
随机推荐
- MySQL网页端在线查询工具
现在许多应用都移到云服务器上面了,数据库的远程维护.监控成为一大问题,通过TreeSoft数据库管理系统,可以方便的使用浏览器,通过网页操作的方式管理MySQL,Oracle,DB2,PostgreS ...
- Scala使用备注一
package com.ws.spark.study.scala import java.io.File import org.scalatest.FlatSpec import scala.io.S ...
- Java进程监控
目录 1.引言 2. 程序启停, 为进程自定义项目名称 3. 操作系统判断 4. 获取进程信息 5. 内存,CPU信息 6. 堆内存信息 7. 端口信息 8. 线程信息 9. MXBean使用样例 9 ...
- 第07组 Alpha冲刺(1/4)
队名:秃头小队 组长博客 作业博客 组长徐俊杰 过去两天完成的任务:完成人员分配,初步学习Android开发 Github签入记录 接下来的计划:继续完成Android开发的学习,带领团队进行前后端开 ...
- Json乱码解决统一代码
我们在springmvc中使用json经常出现乱码格式 如下图: 我们可以在@RequestMapping()中配置,produces = "application/json;charse ...
- mysql插入中文数据变成问号怎么处理
插入中文数据变成问号,一般都是因为字符集没有设置成utf8的原因 1.修改字符集: ALTER TABLE 表名 MODIFY 列名 类型(50) CHARACTER SET "utf8&q ...
- java中拦截器与过滤器之间的区别
过滤器,是在java web中,你传入的request,response提前过滤掉一些信息,或者提前设置一些参数,然后再传入servlet或者struts的 action进行业务逻辑,比如过滤掉非法u ...
- css走马灯,一步一停(专家介绍类型)
<div class="CON--cen-pd3 clear aniview slow" data-av-animation="fadeIn"> & ...
- PHP搭建B2C分销商城系统需要考虑哪些因素?(一)
在网购日渐繁盛的今天,传统线下门店和代理分销越发显示出其弊端.此种情况下,进入互联网市场是最好的选择.入驻第三方平台成本太高,无法掌握自己的流量,所以搭建自己的分销平台成为众多企业的首选.搭建B2C分 ...
- Python学习笔记:格式化输出
%d digit%s string%f float程序运用:name = input("please input your name:")age = int(input(" ...