亲密接触ASP.Net(16)

来源:互联网 发布:怎么看淘宝直通车出价 编辑:程序博客网 时间:2024/06/05 02:13
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
document.write(baiduCproIFrame());-->Cookie

Cookie的用法也和ASP中差不多。比如我们建立一个名为ASPcn,值为飞刀的cookie

HttpCookiecookie=newHttpCookie["ASPcn"];
cookie.Value="飞刀";
Response.AppendCookie(cookie);

我们取出Cookie值也很简单

HttpCookiecookie=Request.Cookies["ASPcn"];
cookieValue=cookie.Value;

有时候我们想在一个Cookie中储存多个信息,那也没有问题。比如我们在名为ASPcn的cookie下加多个信息

HttpCookiecookie=newHttpCookie("ASPcn");
cookie.Values.Add("webmaster","飞刀");
cookie.Values.Add("writer","beige");
cookie.Values.Add("LinkColor","blue");
Response.AppendCookie(cookie);

取出信息也一样简单

HttpCookiecookie=Request.Cookies["ASPcn"];
value1=cookies.Values["webmaster"];
value2=cookies.Values["writer"];

ViewState

这是一个新出来的东东,用法和Session一样,他的主要用途是记录WebControl的状态。虽然是新出来的,但是和Application、Session的用法没有什么区别,所以也不想详细讲解了。

State["DropLoadIndex"]=0;

基本用法如上:),但是请记住,他保存在的信息只能在一个ASPx文件中使用。出去后,这个就没有用了,因为他的用途只是保存WEB控件的状态。

ASP.Net高级应用

ASP.Net的基础部分,我们已经讲解完毕,但是这还不是完部ASP.Net的功能,还有好多的ASP.Net新功能强大的很啊。

WebService
Track
国际化
Cache
制作组件
制件控件

还有好多啊,呵呵,我不可能一口气讲下去了,我们下一个专题就是《ASP.Net高级应用进阶》系列啦。《亲密接触ASP.Net》主要讲基础,呵呵,我已经讲完了:)

另外最近可以可能要写一本关于ASP.Net和C#的书,所以可以在网上写文章的速度就会变慢啦:)

 

<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击