• COOKIES 的使用,事件控制的应用


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    public partial class Default11 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Button1.Click += Button1_Click;
        }
    
        void Button1_Click(object sender, EventArgs e)
        {
            if (TextBox1.Text == "zhangsan" && TextBox2.Text == "123")
            {
                //1、记住当前用户的登陆状态
                Response.Cookies.Add(new HttpCookie("UserName", TextBox1.Text));
    
                Response.Cookies["Pwd"].Value = TextBox2.Text;
    
                //2、是否需要长时间保存
                if (CheckBox1.Checked)
                {
                    Response.Cookies["UserName"].Expires = DateTime.Now.AddDays(7);
                    Response.Cookies["Pwd"].Expires = DateTime.Now.AddDays(7);
                }
                Response.Redirect("Default12.aspx");
            }
            else
            { 
            
            }
        }
    }
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    public partial class Default11 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Button1.Click += Button1_Click;
        }
    
        void Button1_Click(object sender, EventArgs e)
        {
            if (TextBox1.Text == "zhangsan" && TextBox2.Text == "123")
            {
                //1、记住当前用户的登陆状态
                Response.Cookies.Add(new HttpCookie("UserName", TextBox1.Text));
    
                Response.Cookies["Pwd"].Value = TextBox2.Text;
    
                //2、是否需要长时间保存
                if (CheckBox1.Checked)
                {
                    Response.Cookies["UserName"].Expires = DateTime.Now.AddDays(7);
                    Response.Cookies["Pwd"].Expires = DateTime.Now.AddDays(7);
                }
                Response.Redirect("Default12.aspx");
            }
            else
            { 
            
            }
        }
    }
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    public partial class Default13 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Application["aaa"] = "V1.0";
        }
    }
  • 相关阅读:
    Median of Two Sorted Arrays
    Two Sum
    C# Socket服务端和客户端互相send和receive
    C++ 虚函数和虚函数表
    C++ 类型转换
    C# 几种退出程序的方式
    进程判断及简单操作
    C#根据函数名称执行对应的函数
    C# DateTime格式化
    nginx常用代理配置
  • 原文地址:https://www.cnblogs.com/suiyuejinghao123/p/5690234.html
Copyright © 2020-2023  润新知