日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

ASP.NET常用的三十三種實用代碼(2)_.Net教程

編輯Tag賺U幣
教程Tag:暫無Tag,歡迎添加,賺取U幣!

推薦:新手入門之ASP.NET2.0中的緩存技術(shù)解析
ASP.NET2.0提供如下緩存方式: Output Caching Fragment Caching Data Cache SQL Cache Cache Configuration 1. Output Caching: 當一個網(wǎng)頁被頻繁訪問時,我們可以把把整


if (e.Item.ItemType == ListItemType.Item e.Item.ItemType == ListItemType.AlternatingItem)
{
 e.Item.Attributes.Add("onclick","this.style.backgroundColor=’#99cc00’;
  this.style.color=’buttontext’;this.style.cursor=’default’;");
}


寫在DataGrid的_ItemDataBound里


if (e.Item.ItemType == ListItemType.Item e.Item.ItemType == ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("onmouseover","this.style.backgroundColor=’#99cc00’;
 this.style.color=’buttontext’;this.style.cursor=’default’;");
e.Item.Attributes.Add("onmouseout","this.style.backgroundColor=’’;this.style.color=’’;");
}

8.關(guān)于日期格式

日期格式設(shè)定


DataFormatString="{0:yyyy-MM-dd}"


我覺得應(yīng)該在itembound事件中


e.items.cell["你的列"].text=DateTime.Parse(e.items.cell["你的列"].text.ToString("yyyy-MM-dd"))


9.獲取錯誤信息并到指定頁面

不要使用Response.Redirect,而應(yīng)該使用Server.Transfer

e.g

// in global.asax
protected void Application_Error(Object sender, EventArgs e) {
if (Server.GetLastError() is HttpUnhandledException)
Server.Transfer("MyErrorPage.aspx");

//其余的非HttpUnhandledException異常交給ASP.NET自己處理就okay了 :)
}


Redirect會導(dǎo)致post-back的產(chǎn)生從而丟失了錯誤信息,所以頁面導(dǎo)向應(yīng)該直接在服務(wù)器端執(zhí)行,這樣就可以在錯誤處理頁面得到出錯信息并進行相應(yīng)的處理

10.清空Cookie

Cookie.Expires=[DateTime];
Response.Cookies("UserName").Expires = 0


11.自定義異常處理

分享:用 asp.net 動態(tài)設(shè)置 WebService 引用
有時候需要動態(tài)的設(shè)置 WebService 的址,這樣發(fā)布到不同的服務(wù)器時就要重新生成,為此我們需要在web.config中動態(tài)配置WebService的地址,在網(wǎng)上查了很多資料,其中這種方法感覺很好用也很好實現(xiàn)

來源:模板無憂//所屬分類:.Net教程/更新時間:2008-08-22
相關(guān).Net教程