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传值取值的更多相关文章

  1. Mvc4_传值取值应用

    Mvc路由运行机制:   首先,Web 浏览器向服务器发送一条URL 请求,如http://HostName/ControllerName/ActionName/Parameters. 其次,请求被A ...

  2. React使用DVA本地state传值取值

    React使用DVA本地state传值取值 最近在用Ant Pro 做一个后台系统,在使用中发现Antd Pro使用DVA来实现redux+sagas+router一系列的功能,比传统方式要方便快捷的 ...

  3. 微信小程序 传值取值的方法总结

    微信小程序 传值取值的几种方法总结 列表index下标取值 页面传值 form表单取值 1. 列表index下标取值 实现方式是:data-index="{{index}}"挖坑及 ...

  4. 【2017-05-21】WebForm跨页面传值取值、C#服务端跳转页面、 Button的OnClientClick属性、Js中getAttribute和超链接点击弹出警示框。

    一.跨页面传值和取值: 1.QueryString - url传值,地址传值 优缺点:不占用服务器内存:保密性差,传递长度有限. 通过跳转页面路径进行传值,方式: href="地址?key= ...

  5. WebForm跨页面传值取值、C#服务端跳转页面、 Button的OnClientClick属性和超链接点击弹出警示框

    一.跨页面传值和取值: 1.QueryString - url传值,地址传值 优缺点:不占用服务器内存:保密性差,传递长度有限. 通过跳转页面路径进行传值方式: href="地址?key=v ...

  6. 微信小程序传值取值的几种方法

    一,列表index下的取值 实现方式是:data-index="{{index}}"挖坑及e.currentTarget.dataset.index来填坑即可 1.1生成值 < ...

  7. EL表达式从request和session中取值

    在Action中保存登录的基本信息:request.getSession().setAttribute("adminid", str); 在JSP页面中:${sessionScop ...

  8. Spring MVC 常用注解 和session界面渲染取值

    @RequestParams name 修饰当前形参的属性 value 和name属性一样 也是修饰当前属性 defaultValue 给属性设置一个默认值 默认属性 required 必备属性 1. ...

  9. ASP.NET GridView HyperLinkField传值和取值【转】

    来源:http://www.cnblogs.com/junjie94wan/archive/2011/08/17/2143623.html 经常做Winform程序,好久没有做WEB都有些生疏了,Gr ...

随机推荐

  1. ubuntu 18.04安装ftp服务器

    首先安装vsftpd: sudo apt-get install vsftpd 可以通过命令vsftpd -version查看vsftpd版本. 为ftp服务器新建一个用户(比如我这里新建一个用户名和 ...

  2. Flutter dio伪造请求头获取数据

    在很多时候,后端为了安全都会有一些请求头的限制,只有请求头对了,才能正确返回数据.这虽然限制了一些人恶意请求数据,但是对于我们聪明的程序员来说,就是形同虚设.下面就以极客时间为例,讲一下通过伪造请求头 ...

  3. JavaScript快速开发

    c标签导入 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> fn函数 ...

  4. Class WriteGroupAttribute

    [WriteGroup]可以排除在创建已声明写入同一组件的查询时未知的组件. 这允许安全地扩展组件系统而无需编辑先前存在的系统. 目标是为期望将数据从一组组件(输入)转换为另一组(输出[s])的系统能 ...

  5. CodeForces 1251A --- Broken Keyboard

    [CodeForces 1251A --- Broken Keyboard ] Description Recently Polycarp noticed that some of the butto ...

  6. Git速成学习第六课:Bug分支

    Git速成学习笔记整理于廖雪峰老师的官网网站:https://www.liaoxuefeng.com/ 当你接到一个修复代码为101的任务的时候,很自然的你想创建一个分支issue-101来修复它,但 ...

  7. 【DSP开发】帮您快速入门 TI 的 Codec Engine

    德州仪器半导体技术(上海)有限公司 通用DSP 技术应用工程师 崔晶 德州仪器(TI)的第一颗达芬奇(DaVinci)芯片(处理器)DM6446已经问世快三年了.继DM644x之后,TI又陆续推出了D ...

  8. 使用apache-commons-lang3架构对HTML内容进行编码和反编码

    String a="<br>"; String a_str=StringEscapeUtils.escapeHtml4(a);//编码 System.out.print ...

  9. Python报错:TypeError: data type not understood

    K-Means聚类算法 def randCent(dataSet, k): m, n = dataSet.shape # numpy中的shape函数的返回一个矩阵的规模,即是几行几列 centrod ...

  10. js唤醒手机APP

    if (navigator.userAgent.match(/android/i)) { // 通过iframe的方式试图打开APP,如果能正常打开,会直接切换到APP,并自动阻止a标签的默认行为 / ...