如果您決定不使用數據庫,請記住,如果您的應用程序擴展到多個服務器,那麼您可能需要在此時重新訪問您的體系結構,否則您的控件可能會在不同的服務器上顯示不同的信息相同的ID。
如果您對此感到滿意,那麼您可能需要考慮將信息存儲在ASP.NET緩存中,例如
System.Web.Caching.Cache cache = Page.Cache;
List<KeyValuePair<string, object>> controlSetup;
controlSetup = cache.Get("ControlSetup" + this.Id.ToString());
if (controlSetup == null)
{
// Create the control setup from scratch
// Put the created control setup into the cache
cache.Put("ControlSetup" + this.Id.ToString(), controlSetup);
}
foreach (KeyValuePair(string, object) item In controlSetup
{
// Set the control values
}
在Web上,在使用'static'之前請三思。 – 2010-09-27 08:28:39