Substitution Control in ASP.NET
In this article we will learn how to use Substitution control in ASP.NET.
In this article we will learn how to use Substitution control in ASP.NET.
Substitution control
Substitution control is used to call a method that returns a string in an output-cached page.
Properties: The main property of the Substitution control is MethodName.

Figure 1.
MethodName - MethodName are Used to assign method name that will fire each time page will load and return the string. Please note that this method will be a static method.
For example: The below figure shows the Substitution control.

Figure 2.
Now click on the source button of the design form.
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm2.aspx.vb" Inherits="WebApplication34.WebForm2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head id="Head1" runat="server">
<title>Post Cache Substitution</title>
</head>
<body>
<form id="form1" runat="server">
<h4>
This page uses post cache substitution to insert a dynamic value into a cached page.</h4>
<p>
DateTime using cheched:
<%= DateTime.Now.ToString() %>
</p>
<p>
<b>DateTime using Substitution:
<asp:Substitution ID="Substitution1" runat="server" MethodName="GetCurrentDate" />
</b>
</p>
</form>
</body>
</html>
Now double click on the form and create a method GetCurrentDate calling through the MethodName property.
Shared Function GetCurrentDate(ByVal context As HttpContext) As String
Return Now.ToString()
End Function
Now save and run the application.

Figure 3.