ÈÃViewState ±£´æÓÚ·þÎñÆ÷¶ËÎļþ (asp.net C#)
½«ViewState³Ö¾Ã»¯±£³ÖÔÚ·þÎñÆ÷¶ËÎļþµÄ´úÂ룬ÕâÑùViewState²»Õ¼ÓÃÍøÂç´ø¿í£¬Òò´ËÆä´æÈ¡Ö»ÊÇ·þÎñÆ÷µÄ´ÅÅ̶Áȡʱ¼ä¡£²¢ÇÒËüºÜС£¬¿ÉÒÔ˵ÊÇ´ÅÅÌËæ±ãתһȦ¾ÍÄÜͬʱ¶ÁÈ¡ºÃ¶àViewState£¬Òò´Ë¿ÉÒÔ˵“²»Õ¼Ê±¼ä”¡£ÎªÁËÔÙ“²»Õ¼´ÅÅÌʱ¼ä”£¬ÎÒ»¹Ê¹ÓÃÁË»º´æ¡£
´´½¨Ò»¸ö»ùÀà:
public class
BasePage : System.Web.UI.Page
{
protected override object
LoadPageStatefromPersistenceMedium()
{
var viewStateID = (string)((Pair)base.LoadPageStatefromPersistenceMedium()).Second;
var stateStr = (string)Cache[viewStateID];
if (stateStr == null)
{
var fn = Path.Combine(this.Request.PhysicalApplicationPath, @"App_Data/ViewState/" + viewStateID);
stateStr = File.ReadAllText(fn);
}
return new ObjectStateFormatter().Deserialize(stateStr);
}
protected override void
SavePageStateToPersistenceMedium(object state)
{
var value = new ObjectStateFormatter().Serialize(state);
var viewStateID = (DateTime.Now.Ticks + (long)this.GetHashCode()).ToString(); //²úÉúÀëÉ¢µÄidºÅÂë
var fn = Path.Combine(this.Request.PhysicalApplicationPath, @"App_Data/ViewState/" + viewStateID);
ThreadPool.QueueUserWorkItem(obj => File.WriteAllText(fn, value));
Cache.Insert(viewStateID, value);
base.SavePageStateToPersistenceMedium(viewStateID);
}
}
}
Global.asax,ÒÔÏ´úÂëÒ²¿ÉÒÔ²»Óãº
protected void
Application_Start(object sender, EventArgs e)
{
DirectoryInfo dir = new DirectoryInfo(this.Server.MapPath("~/App_Data/ViewState/"));
if (!dir.Exists)
dir.Create();
else
{
DateTime nt = DateTime.Now.AddHours(-0.3); //ɾ³ý15·ÖÖÓÒÔÇ°µÄ»º´æÎļþ
FileInfo[] fiArr = dir.GetFiles();
foreach (FileInfo f in fiArr)
{
if (f.CreationTime < nt)
{
f.Delete();
}
}
}
}
ʹÓ÷½·¨:
ÆäËüÒ³Ã
Ïà¹ØÎĵµ£º
µÚÒ»ÖÖÊÇÔÚapsxÒ³ÃæÉÏ·ÅÒ»¸öLable¿Ø¼þ
ÕâÖÖ·½Ê½¿ÉÒÔдJavascriptµÈ¿ØÖÆÒ³Ã棬ºÍ²¼¾ÖÒ³Ãæ
ÈçÏ£ºHTMLÒ³Ãæ´úÂ룺
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<TITLE>¶àýÌå²¥·ÅÒ³Ãæ</TITLE>
<meta content=" ......
ÎÒÃÇÔÚAsp.Net¿ª·¢¹ý³ÌÖУ¬ÓÐʱºòΪÁË¿ª·¢µÄÐèÒª£¬»ò´ïµ½Ò»¶¨µÄЧ¹û£¬ÎÒÃÇ»á²ÅÈ¡¶¯Ì¬¼ÓÔØÓû§¿Ø¼þµÄ·½·¨À´ÊµÏÖ£¬¶¯Ì¬¼ÓÔØÓû§¿Ø¼þ£¬¿ÉÒÔÔÚͬһ¸öÒ³ÃæÀïÃ棬¸ù¾Ý²»Í¬µÄÇé¿öÏÔʾ²»Í¬µÄÄÚÈÝ£¬Ê¹ÎÒÃÇÔÚ¿ª·¢Ê¡Ê±Ê¡Á¦¡£
¡¡ÄÇôÎÒÃÇÔõôʵÏÖ¶¯Ì¬¼ÓÔØÓû§¿Ø¼þÄØ£¬ÆäʱºÜ¼òµ¥£¬ÎÒÃÇÖ»ÒªÔÚÒ³ÃæÀïÒª·Å¿ØµÄ¼þµÄµØ·½·ÅÒ»¸öռλ¿Ø¼þ &l ......
1¡¢ExcelÊý¾Ýµ¼Èëµ½Êý¾Ý¿âÖУº
//¸Ã·½·¨ÊµÏÖ´ÓExcelÖе¼³öÊý¾Ýµ½DataSetÖУ¬ÆäÖÐfilepathΪExcelÎļþµÄ¾ø¶Ô·¾¶£¬sheetnameΪ±íʾÄǸöExcel±í£»
public DataSet ExcelDataSource( string filepath , string sheetname )
&nb ......
×î½üÔÚÕÒÊý¾Ýµ¼³öµ½EXCELµÄ·½·¨£¬·¢ÏÖÖñÁÖbat800ÔÚblogÖз¢²¼µÄ·½·¨£¬ÎªÁ˱ãÓÚÒÔºó²éÕÒתµ½×Ô¼ºblogÏÂ
http://blog.csdn.net/bat800/archive/2007/07/17/1694537.aspx
ÕâÊÇÔÎĵØÖ·
Ò»¡¢asp.netÖе¼³öExeclµÄ·½·¨£º
ÔÚasp.netÖе¼³öExeclÓÐÁ½ÖÖ·½·¨£¬Ò»ÖÖÊǽ«µ¼³öµÄÎļþ´æ·ÅÔÚ·þÎñÆ÷ij¸öÎļþ¼ÐÏÂÃ棬Ȼºó½«ÎļþµØÖ·Êä³ö ......
ÈÎÖ°×ʸñ:
1. ´óѧ±¾¿ÆÒÔÉÏѧÀú£¬ÈýÄêÒÔÉÏÈí¼þ¿ª·¢¹¤×÷¾Ñé»ò»¥ÁªÍø¿ª·¢¾Ñ飻¾ßÓжþ¸ö¼°ÒÔÉÏÖÐÐÍÏîÄ¿µÄ³É¹¦ÊµÊ©¾Ñ飻
2. ÓÐ׼ȷÀí½âÐèÇ󡢼ܹ¹ÄÜÁ¦£¬ÓнÏÇ¿µÄ³ÌÐòÉè¼ÆÄÜÁ¦, ÊìϤÃæÏò¶ÔÏó·ÖÎö¡¢Èí¼þ¹¤³Ì¡¢UMLµÈÏà¹Ø¼¼Êõ£»
3. ÊìÁ·ÕÆÎÕ¼ÆËã»ú±à³ÌÒ»°ã˼ÏëºÍ·½·¨£»ÊìϤһÖÁÁ½ÖÖÃæÏò¶ÔÏó±à³ÌÓïÑÔ£»¾«Í¨.NET¡¢ C#¡¢ASP.net¡ ......