时间:2021-07-01 10:21:17 帮助过:15人阅读
1. 服务端代码,Page_Load里面Cookies写入几个值
using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WebApplication_TestJS { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Response.Cookies["DONO"].Value = "EDO1406300001"; Response.Cookies["DOID"].Value = "ABCDEFG123456"; Response.Cookies["DOSOURCE"].Value = "WUWUWUWU"; Response.Cookies["DOTYPE"].Value = "2"; } } }
2. 客户端代码,页面添加按钮和文本框,用于触发和输出获取到的值
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication_TestJS._Default" %>
3.执行结果,可以看到Cookies就是如第一个文本框中存放结构,根据需要截取相应字符串即可