ASP.Net/Development/Callback — различия между версиями

Материал из .Net Framework эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Версия 15:30, 26 мая 2010

HttpResponseSubstitutionCallback

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Default" %>
<%@ OutputCache Duration="5" VaryByParam = "none" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    </div>
    </form>
</body>
</html>
File: Default.aspx.vb

Partial Class Default
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, _
                            ByVal e As System.EventArgs) _
                            Handles Me.Load
        Response.Write("Current (cached) Time is :" & Now)
        Response.Write("<br/>")
        Response.WriteSubstitution(New HttpResponseSubstitutionCallback(AddressOf getServerTime))
    End Sub
    Public Shared Function getServerTime(ByVal context As System.Web.HttpContext) _
       As String
        Return "Current Time is :" & Now.ToString
    End Function
End Class