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

Asp.net 中 Cookie的使用方法

方法1:
比如建立一个名为cnlive,值为"123"的cookie
HttpCookie cookie = new HttpCookie["cnlive"];
cookie.Value = "123";
Response.AppendCookie(cookie);
取刚才写入的Cookie值:
HttpCookie cookie = Request.Cookies["cnlive"];
cookieValue = cookie.Value;
在一个Cookie中储存多个信息:
HttpCookie cookie = new HttpCookie("cnlive");
cookie.Values.Add("weburl",http://www.cnlive.net);
cookie.Values.Add("author","honfei");
cookie.Values.Add("sitename","网友与媒体");
Response.AppendCookie(cookie);
读取:
HttpCookie cookie = Request.Cookies["cnlive"];
value1 = cookies.Values["weburl"];
value2 = cookies.Values["author"];
.............
方法二:
Response.Cookies["UserID"].Value = "123";//将用户ID写入Cookie
Response.Cookies["UserID"].Expires = DateTime.Now.AddDays(1);
读取方法:
Request.Cookies["UserID"].Value;
写cookie
HttpCookie cookie = new HttpCookie("Info");//定义cookie对象以及名为Info的项
DateTime dt = DateTime.Now;//定义时间对象
TimeSpan ts=new TimeSpan(1,0,0,0);//cookie有效作用时间,具体查msdn
cookie.EXPires = dt.Add(ts);//添加作用时间
cookie.Values.Add("user","cxbkkk");//增加属性
cookie.Values.Add("userid","1203");
Response.AppendCookie(cookie);//确定写入cookie中 读取cookie
if(Request.Cookies["Info"]!=null)
{
string temp=Convert.ToString(Request.Cookies["Info"].Values["user"])+" "+Convert.ToString(Request.Cookies["Info"].Values["userid"]);
//读全部就用Request.Cookies["Info"].Value)
if(temp=="")
{
Response.Write("空");
}
else
Response.Write(temp);
}
else
{
Response.Write("error");
} 修改cookie
Response.Cookies["Info"]["user"] = "2";
Response.Cookies["Info"].Expires = DateTime.Now.AddDays(1);
// 删除cookie下的属性
HttpCookie acookie=Request.Cookies["Info"];
acookie.Values.Remove("userid");
acookie.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(acookie); 删除所有cookie,就是设置过期时间为现在就行了
int limit=Request.Cookies.Count - 1;
for(int i=0;i<limit;i++)
{
acookie = Request.Cookies(i)
acookie.Expires = DateTime.N


相关文档:

asp.net下后台常用分页解决方案的思考

SQL
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go


--阿会楠sosuo8.com根据网络上的代码进行了修改,版权归原作者所有2009-4-5
--阿会楠做了一次升级,2009-9-27
--修改输出总记录数

ALTER PROCEDURE [dbo].[pagination]
@tblName nvarchar(1000), -- 表名
......

asp.net 庶罩层上传图片(二进制),并显示二进制图片

1.上传功能
JS检查
function hideUpImg()//关闭层,并上传图片
{
var v=document.getElementById("upImg").value;
var after=v.substring(v.lastIndexOf('.')).toLowerCase();
alert(after);
if(v.length<=0)
{
alert("请选择图片");
return ......

关于ASP.NET控件在编译时找不到的解决方案

     本人开发ASP.NET已有两年多了。谈起ASP.NET真是让我欢喜让我忧。昨天又出现了那个奇怪的问题,就是在页面完全写好后,重新生成时报:XXX(页面名)不包含(XXX)的定义。在CS文件下是可以用 this.xxx 写出来的,页面上也没问题。在解决方案中重新生成页又可以,重新生成网站就会报这个错误。将this.XXX ......

ASP.NET中防止页面多次提交的代码实现

1.   
此处提供的代码用来实现当asp.net
页面中的某个Button
被点击后disable
掉该页面中所有的Button
,从而防止提交延时导致的多次提交。基于之前的onceclickbutton
脚本.
//ASP.NET
中防止页面多次提交的代码:javascript< script
language="javascript"> < !-- function dis ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号