protected void PageLoadobject sender Event Args e if
关键代码:验证回传 protected void Page_Load(object sender, Event. Args e) { if (Page. Is. Post. Back) {. . . } } Is. Post. Back常放置于Page_Load方法中 用于首次加载页面时的初始化
关键代码 发出提交的页面 通过Post. Back. Url指定获取页 <asp: Button ID="btn. Ok" runat="server" Post. Back. Url="~/Post. Back. aspx" Text="查询" /> 获取内容的页面 if (Page. Previous. Page!=null) 判断该页面的是否为其他页回传 { if(Previous. Page. Is. Cross. Page. Post. Back == true) { this. lbl. Show. URL. Text = "您的查询条件为:" + ((Text. Box)this. Previous. Page. Find. Control("txt. Key. Word")). Text; } 获取控件值 }
关键代码 登录代码 User user = new User(); user. Id = 0; user. User. Name = txtlogin. Id. Text; user. Pass. Word = txt. Login. Pwd. Text; Session["User"] = user; Session的名称 要存储的对象 索引器 使用索引器[ ],可以像数组一样处理Session对象 JSP中session. set. Attribute("username", username)
关键代码 写入Cookie代码 Http. Cookie hc. Cookie = new Http. Cookie("User. Name", “张三"); Response. Cookies. Add(hc. Cookie); 添加新的Cookie 读取Cookie代码 string User. Name=Request. Cookies["User. Name"]. Value;
Thank you
- Slides: 33