I want to show Components in a tabs , so first of all create few components. In this project we have three components, First View Component public class AllViewComponent : ViewComponent { private readonly UserManager<ApplicationUser> _userManager; public AllViewComponent(UserManager<ApplicationUser> userManager) { _userManager = userManager; } public async Task<IViewComponentResult> InvokeAsync() { List<StudentViewModel> allUsers = new List<StudentViewModel>(); var items = await _userManager.Users.ToListAsync(); foreach (var item in items) { allUsers.Add(new StudentViewModel {Id=item.Id, EnrollmentNo = item.EnrollmentNo, FatherName = item.FatherName, Name = item.Name, Age = item.Age, Birthdate = item.Birthdate, Address = item.Address, Gender = item.Gender, Email = item.Email }); }
The substitution control is used to specify a section on an output-cached Web page where you want to substitute the dynamic content for the control. This control provides a simplified solution to partial page caching for pages where the majority of the content is cached. You can output cache the entire page, and then use the Substitution control to specify the sections of the page that are exempted from caching.
Public Properties of the Substitution class
MethodName : Callback method to call up when the Substitution control executes.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="substitution.aspx.cs" Inherits="substitution" %>
<%@ OutputCache Duration="300" VaryByParam="none" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script runat="server">
static string dotprogramming(HttpContext context) {
string name = DateTime.Now.ToString();
return name;
}
</script>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Page Cached DateTime<br />
<%= DateTime.Now.ToString() %>
<br />
Current Time without cache<br />
<asp:Label ID="Label2" runat="server" Text=""></asp:Label>
<asp:Substitution ID="Substitution1" runat="server"
MethodName="dotprogramming" />
</div>
</form>
</body>
</html>
In this example page cached for 300 seconds using OutputCache directive , But you can refresh content using Substitution control.
Code Generate the following Output
Comments
Post a Comment