易截截图软件、单文件、免安装、纯绿色、仅160KB

ASP.NET页面传值_第六篇_Cookie

+++ Cookie01.aspx页面
++ 页面代码如下:
<asp:TextBox ID="TextBox1" runat="server" ForeColor="Red" Width="182px">Name</asp:TextBox>
<asp:Button ID="BtnCookie" runat="server" OnClick="BtnCookie_Click" Text="BtnCookie" /><br />
++ 后台代码如下:
protected void BtnCookie_Click(object sender, EventArgs e)
{
  Response.Cookies["Name"].Value = TextBox1.Text;
  Response.Cookies["Name"].Expires = DateTime.Now.AddDays(1);
  HttpCookie aCookie = new HttpCookie("lastVisit");
  aCookie.Value = DateTime.Now.ToString();
  aCookie.Expires = DateTime.Now.AddDays(1);
  Response.Cookies.Add(aCookie);
  Response.Redirect("Cookie02.aspx");
}
+++ Cookie02.aspx页面
++ 页面代码如下:
(略)
++ 后台代码如下:
protected void Page_Load(object sender, EventArgs e)
{
    #region 读取Cookie
    if (Request.Cookies["Name"] != null)
    {
        Response.Write(Server.HtmlEncode(Request.Cookies["Name"].ToString()) + "</br>");
    }
    if (Request.Cookies["lastVisit"] != null)
    {
        HttpCookie aCookie = Request.Cookies["lastVisit"];
        Response.Write(Server.HtmlEncode(aCookie.Value) + "</br>");
    }
    #endregion
    Response.Write("</br>");
    #region 删除Cookie
    HttpCookie dCookie;
    string cookieName;
    int limit = Request.Cookies.Count;
    for (int i = 0; i < limit; i++)
    {
        cookieName = Request.Cookies[i].Name;
        dCookie = new HttpCookie(cookieName);
        dCookie.Expires = DateTime.Now.AddDays(-1);
 &


相关文档:

《ASP.NET MVC案例教程》索引贴

      本系列文章通过一个虚拟的案例——《MVC公告发布系统》的开发过程,全面展示了ASP.NET MVC的基本使用方法,同时在讨论了这个框架的基本原理。
      这个文章系列的目的就是使朋友们更轻松的入门ASP.NET MVC。
      这个系 ......

WCF 与 Asp.net Web service 比较

首先简单介绍一下 WCF 是什么,然后再对 WCF 和 Asp.net Web service 做个比较。
    Windows Communication Foundation (WCF) 是用于构建面向服务的应用程序的框架。借助 WCF,可以将数据作为异步消息从一个服务终结点发送至另一个服务终结点。服务终结点可以是由 IIS 承载的持续可用的服务的一部分,也可 ......

Asp.Net前台调用后台变量

1.Asp.Net中几种相似的标记符号: < %=...%>< %#... %>< % %>< %@ %>解释及用法
答: < %#... %>: 是在绑定控件DataBind()方法执行时被执行,用于数据绑定
如: < %# Container.DataItem("tit") %>
< %= %>: 在程序执行时被调用,可以显示后台变量值
如:
*.aspx中: < %= a ......

ASP.NET页面传值_第三篇_ViewState

+++ 页面代码如下:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /><br />
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
+++ 后台代码如下:
protected void Butto ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号