ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Cache specific section of Page in ASP.Net using C# and VB.Net<p>I will get back soon.</p>https://www.aspforums.net:443/Threads/662174/Cache-specific-section-of-Page-in-ASPNet-using-C-and-VBNet/https://www.aspforums.net:443/Threads/662174/Cache-specific-section-of-Page-in-ASPNet-using-C-and-VBNet/Wed, 19 Dec 2018 02:59:06 GMTCache specific section of Page in ASP.Net using C# and VB.Net<p>Hey <a class="username" rel="khatri852">khatri852</a>,</p> <p>Please refer below sample.</p> <p><span style="text-decoration: underline;"><strong>HTML</strong></span></p> <pre class="brush: html">&lt;%@ OutputCache Duration=&#34;5&#34; VaryByParam=&#34;none&#34; %&gt; &lt;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&gt; &lt;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&gt; &lt;head id=&#34;Head1&#34; runat=&#34;server&#34;&gt; &lt;title&gt;Substitution Class Example&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form id=&#34;form1&#34; runat=&#34;server&#34;&gt; &lt;p&gt; This section of the page is not cached:&lt;/p&gt; &lt;asp:Substitution ID=&#34;Substitution1&#34; MethodName=&#34;GetCurrentDateTime&#34; runat=&#34;Server&#34;&gt; &lt;/asp:Substitution&gt; &lt;br /&gt; &lt;p&gt; This section of the page is cached:&lt;/p&gt; &lt;asp:Label ID=&#34;lblDate&#34; runat=&#34;Server&#34;&gt; &lt;/asp:Label&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </pre> <p><span style="text-decoration: underline;"><strong>Code</strong></span></p> <pre class="brush: csharp">protected void Page_Load(object sender, EventArgs e) { lblDate.Text = DateTime.Now.ToString(); } public static string GetCurrentDateTime(HttpContext context) { return DateTime.Now.ToString(); }</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load lblDate.Text = DateTime.Now.ToString() End Sub Public Shared Function GetCurrentDateTime(ByVal context As HttpContext) As String Return DateTime.Now.ToString() End Function</pre> <p><span style="text-decoration: underline;"><strong>Screenshot</strong></span></p> <p><img src="https://imgur.com/8dezCYS.gif" alt="" width="339" height="240" /></p>https://www.aspforums.net:443/Threads/662174/Cache-specific-section-of-Page-in-ASPNet-using-C-and-VBNet/https://www.aspforums.net:443/Threads/662174/Cache-specific-section-of-Page-in-ASPNet-using-C-and-VBNet/Wed, 19 Dec 2018 03:52:39 GMT