This documentation is archived and is not being maintained.

Substitution.MethodName Property

Gets or sets the name of the callback method to invoke when the Substitution control executes.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

Public Overridable Property MethodName As String
<asp:Substitution MethodName="String" />

Property Value

Type: System.String
A string that represents the name of the method to invoke when the Substitution control executes.

Use the MethodName property to specify the name of the callback method to invoke when the Substitution control executes. The callback method that you specify must be a static method on the page or user control that contains the Substitution control. The signature for the callback method must match the signature for a HttpResponseSubstitutionCallback delegate that takes an HttpContext parameter and returns a string. The string that the callback method returns is the content to display on the page at the location of the Substitution control.

The HttpContext parameter encapsulates all HTTP-specific information about an individual HTTP request. You can use it to access session variables, authorization information, and personalization details. For more information, see HttpResponseSubstitutionCallback.

The following code example demonstrates how to add a Substitution control declaratively to an output-cached Web page. When the page loads, a static bulleted list is displayed to the user. This section of the page is cached and updated only every 60 seconds. When the Substitution control executes, it calls the GetUser method, which returns a string that represents the current user. This string is displayed at the location of the Substitution control on the page. This section of the page is not cached and is updated each time the page is refreshed.

<%@ outputcache duration="60" varybyparam="none" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<script runat="server" language="VB">  

  ' The Substitution control calls this method to retrieve
  ' the name of the current user from the HttpContext object. 
  ' This section of the page is exempt from output caching. 
  Shared Function GetUser(ByVal context As HttpContext) As String
    Return context.User.Identity.Name
  End Function


<html xmlns="" >
<head id="Head1" runat="server">
  <title>Substitution.MethodName Property Example</title>
  <form id="Form1" runat="server">

    <h3>Substitution.MethodName Property Example</h3>  

    <!--This section of the page is not cached.-->
    Welcome to the site,
    <asp:substitution id="Substitution1"

    <br /><br />

    <!--This section of the page is cached.-->
    Product list:
    <asp:bulletedlist id="ItemsBulletedList"             
        <asp:ListItem>Product 1</asp:ListItem>
        <asp:ListItem>Product 2</asp:ListItem>
        <asp:ListItem>Product 3</asp:ListItem>


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.