本文整理汇总了C#中System.Web.UI.PartialCachingAttribute类的典型用法代码示例。如果您正苦于以下问题:C# PartialCachingAttribute类的具体用法?C# PartialCachingAttribute怎么用?C# PartialCachingAttribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PartialCachingAttribute类属于System.Web.UI命名空间,在下文中一共展示了PartialCachingAttribute类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_Load
// [filename partialcache.cs]
// Create a code-behind user control that is cached
// for 20 seconds using the PartialCachingAttribute class.
// This control uses a DataGrid server control to display
// XML data.
using System;
using System.IO;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Samples.AspNet.CS.Controls
{
// Set the PartialCachingAttribute.Duration property to 20 seconds.
[PartialCaching(20)]
public partial class ctlMine : UserControl
{
protected void Page_Load(Object Src, EventArgs E)
{
DataSet ds = new DataSet();
FileStream fs = new FileStream(Server.MapPath("schemadata.xml"), FileMode.Open, FileAccess.Read);
StreamReader reader = new StreamReader(fs);
ds.ReadXml(reader);
fs.Close();
DataView Source = new DataView(ds.Tables[0]);
// Use the LiteralControl constructor to create a new
// instance of the class.
LiteralControl myLiteral = new LiteralControl();
// Set the LiteralControl.Text property to an HTML
// string and the TableName value of a data source.
myLiteral.Text = "<h6><font face=verdana>Caching an XML Table: " + Source.Table.TableName + " </font></h6>";
MyDataGrid.DataSource = Source;
MyDataGrid.DataBind();
TimeMsg.Text = DateTime.Now.ToString("G");
}
}
}