Substitution Control in ASP.Net

The new <asp: substitution> control gives you a placeholder into which you can write dynamic content when using output caching. The Substitution control lets you create areas on the page that can be updated dynamically and then integrated into a cached page.

You can place a Substitution server control at the page location where content should be substituted, and set its MethodName property to the callback method.

<asp:Substitution ID="Substitution1" runat="server" />

Substitution Control in ASP.Net

Substitution Control in ASP.Net

<asp:Substitution ID="Substitution1" runat="server"   MethodName="GetCurrentDate">

</asp:Substitution>

 

GetCurrentDate is a function.

Substitution control is used to call a method that returns a string in an output-cached page.

<script runat="server">

    static string GetCurrentDate(HttpContext xyz)

    {

        return DateTime.Now.ToString();

    }

</script>

 

When we run above code the current date time will show on the page

 

Substitution Control in ASP.Net

  Modified On Nov-29-2017 06:08:49 AM

Leave Comment