本文整理匯總了C#中System.Web.UI.ControlCachePolicy類的典型用法代碼示例。如果您正苦於以下問題:C# ControlCachePolicy類的具體用法?C# ControlCachePolicy怎麽用?C# ControlCachePolicy使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ControlCachePolicy類屬於System.Web.UI命名空間,在下文中一共展示了ControlCachePolicy類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Page_Load
//引入命名空間
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
[PartialCaching(100)]
public partial class SimpleControl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
ItemsRemaining.Text = GetAvailableItems().ToString();
CacheTime.Text = DateTime.Now.ToLongTimeString();
}
private int GetAvailableItems()
{
SqlConnection sqlConnection = new SqlConnection
("Initial Catalog=Northwind;Data Source=localhost;Integrated Security=SSPI;");
SqlCommand sqlCommand = sqlConnection.CreateCommand();
sqlCommand.CommandType = CommandType.StoredProcedure;
sqlCommand.CommandText = "GetRemainingItems";
sqlConnection.Open();
int items = (int)sqlCommand.ExecuteScalar();
sqlConnection.Close();
return items;
}
}