Substitution.MethodName 属性
来源:互联网 发布:如何定义数组的数组 编辑:程序博客网 时间:2024/06/05 17:59
命名空间:System.Web
程序集:System.Web(在 system.web.dll 中)
Public Delegate Function HttpResponseSubstitutionCallback ( _ context As HttpContext _) As String
Dim instance As New HttpResponseSubstitutionCallback(AddressOf HandlerMethod)
public delegate string HttpResponseSubstitutionCallback ( HttpContext context)
public delegate String^ HttpResponseSubstitutionCallback ( HttpContext^ context)
/** @delegate */public delegate String HttpResponseSubstitutionCallback ( HttpContext context)
JScript 支持使用委托,但不支持进行新的声明。
参数
- context
包含对页的 HTTP 请求信息的 HttpContext,该页带有需要缓存后替换的控件。
返回值
在发送到客户端之前插入到缓存的响应的内容。将 HttpResponseSubstitutionCallback 委托用于 WriteSubstitution 方法,可呈现 Substitution 和 AdRotator 控件缓存后内容。
对于 Substitution 控件,则使用 MethodName 属性来指定要在 Substitution 控件执行时调用的回调方法的名称。您指定的回调方法必须是包含 Substitution 控件的页或用户控件上的静态方法。回调方法的签名必须与接受 HttpResponseSubstitutionCallback 参数并返回字符串的 HttpContext 委托的签名匹配。
对于 AdRotator 控件,除非为 AdCreated 事件提供了事件处理程序,否则该控件的呈现不受页缓存的影响。如果未提供 AdCreated 事件处理程序,则使用缓存后替换来呈现 AdRotator 内容。
下面的代码示例演示如何以编程方式将 Substitution 控件添加到输出缓存网页。加载页面时,将在一个标签中向用户显示当前的日期和时间。页面中的此区域每 60 秒缓存并更新一次。当 Substitution 控件执行时,它调用 GetCurrentDateTime 方法,该方法必须匹配 HttpResponseSubstitutionCallback 委托的签名。GetCurrentDateTime 方法返回的字符串将显示给用户。每次刷新页时,都不会缓存和更新页中的这一部分。Substitution 控件的 MethodName 属性获取或设置回调方法的名称。
<%@ outputcache duration="60" varybyparam="none" %><script runat="server" language="VB"> Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) ' Programmatically create a Substitution control. Dim Substitution1 As New Substitution ' Specify the callback method. Substitution1.MethodName = "GetCurrentDateTime" ' Add the Substitution control to the controls ' collection of PlaceHolder1. PlaceHolder1.Controls.Add(Substitution1) ' Display the current date and time in the label. ' Output caching applies to this section of the page. CachedDateLabel.Text = DateTime.Now.ToString() End Sub ' The Substitution control calls this method to retrieve ' the current date and time. This section of the page ' is exempt from output caching. Shared Function GetCurrentDateTime(ByVal context As HttpContext) As String Return DateTime.Now.ToString() End Function </script><html><head id="Head1" runat="server"> <title>Substitution Constructor Example</title></head><body> <form id="Form1" runat="server"> <h3>Substitution Constructor Example</h3> <p>This section of the page is not cached:</p> <asp:placeholder id="PlaceHolder1" runat="Server"> </asp:placeholder> <br /> <p>This section of the page is cached:</p> <asp:label id="CachedDateLabel" runat="Server"> </asp:label> <br /><br /> <asp:button id="RefreshButton" text="Refresh Page" runat="Server"> </asp:button> </form></body></html>
<%@ outputcache duration="60" varybyparam="none" %><script runat="server" language="C#"> void Page_Load(object sender, System.EventArgs e) { // Programmatically create a Substitution control. Substitution Substitution1 = new Substitution(); // Specify the callback method. Substitution1.MethodName = "GetCurrentDateTime"; // Add the Substitution control to the controls // collection of PlaceHolder1. PlaceHolder1.Controls.Add (Substitution1); // Display the current date and time in the label. // Output caching applies to this section of the page. CachedDateLabel.Text = DateTime.Now.ToString(); } // The Substitution control calls this method to retrieve // the current date and time. This section of the page // is exempt from output caching. public static string GetCurrentDateTime (HttpContext context) { return DateTime.Now.ToString (); } </script><html><head id="Head1" runat="server"> <title>Substitution Class Example</title></head><body> <form id="Form1" runat="server"> <h3>Substitution Constructor Example</h3> <p>This section of the page is not cached:</p> <asp:placeholder id="PlaceHolder1" runat="Server"> </asp:placeholder> <br /> <p>This section of the page is cached:</p> <asp:label id="CachedDateLabel" runat="Server"> </asp:label> <br /><br /> <asp:button id="RefreshButton" text="Refresh Page" runat="Server"> </asp:button> </form></body></html>
- Substitution.MethodName 属性
- Substitution控件
- substitution控件
- string substitution
- Bad substitution
- UnityEngine.Component.SendMessage(string methodName)
- [Cryptography]Simple Substitution Cipher
- Liskov Substitution Principle
- String substitution in scripts
- Confusion, diffusion, Collision, Substitution
- Substitution 控件学习
- zoj 1831 Substitution Cypher
- ruby String substitution
- ASP.NET Substitution控件
- zoj 1831 Substitution Cypher
- Bash Commands - $ # Variable Substitution
- [Linux] [bash] Command Substitution
- ZOJ 1831 Substitution Cypher
- 程序员如何缓解压力,保持心理健康
- XML手记三
- [算法]连续正整数问题(续)
- 修改bug心得一
- 求平方根
- Substitution.MethodName 属性
- 央视新台址年底可封顶 建成后将成北京最高建筑
- 疑似遭到攻击,各位老大帮忙看看,手机网址之间(www.mobi123.cn)
- asp.net2.0 URl重定向
- 如何使用SOAP:Lite Perl程序库调用基于.Net框架的Web服务
- 一般图像检索过程
- 中间层模式
- 高手与菜鸟,思想与技术
- 让脚本为开发服务