Microsoft.SharePoint.WebCon ...


PostCacheSubstitutionTextType Enumeration (Microsoft.SharePoint.WebControls)

Namespace: Microsoft.SharePoint.WebControls
Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll)
Syntax

Visual Basic (Declaration)
Public Enumeration PostCacheSubstitutionTextType
Visual Basic (Usage)
Dim instance As PostCacheSubstitutionTextType
C#
public enum PostCacheSubstitutionTextType
Members

  Member name Description
Invalid 
UserEmail 
UserId 
UserLoginName 
UserName 
WebTitle 
WelcomeUser 
See Also

Tags :


Community Content

Adam Buenz - MVP
PostCacheSubstitutionTextType

Description

The Microsoft.SharePoint.WebControls.PostCacheSubstitutionTextType enumeration is used in combination with the Microsoft.SharePoint.WebControls.PostCacheSubstitutionText type to support Post-Cache Substitution within SharePoint. Understanding the use of the PostCacheSubsitutionTextType enumeration is heavily related to the difference between fragment caching, where a small portion of the page is cached, as opposed to Post-Cache Substitution where the entire page is cached, except a much smaller segment that is kept dynamic. Post-Cache Substitution was introduced in ASP.NET 2.0 in order to dynamically update portions of cached WebForms for performance reasons.

When ASP.NET retrieves the cached page, the callback methods to the dynamic content are triggered, then that content is inserted into the cached page. The PostCacheSubstitutionText class provides inherent mechanisms to strongly type and manage this content, as well as ensure it is an actual user, and not a robot.

The type of content managed is can be built against PostCacheSubstitutionTextType enumeration. For example, there are SharePoint hooks to manage common text output like username and web titles. Class reference wise, within the Microsoft.SharePoint.WebControls.PersonalActions the UserId is targeted by specifying the PostCacheSubstitutionText.TextType property as PostCacheSubstitutionTextType.UserId.

The purpose of the Microsoft.SharePoint.WebControls.PostCacheSubstitutionTextType enumeration is as categorize flags the types of dynamic content that are supported.

Invalid – invalid piece of dynamic content
UserName – current user name
UserLoginName – current user login name
UserId – current user ID
UserEmail – current user email
WelcomeUser – welcome user control text

Usage Scenario

The primary usage of the PostCacheSubstitutionTextType enumerations is internal, used by the PostCacheSubstitutionText class to categorize types of cached content. There is little use for the enumeration within custom code.

In the below example, MyClass is inheriting from the System.Web.UI.WebControls.WebParts.WebPart class. Within the class the LoadViewState method is overriding which takes an object as a parameter representing the saved state. The ViewState is then checked to see if "TextType" is null. If not, a new PostCacheSubstitutionTextType object is exposed by using an explicit cast.

C# Code Example

public class MyClass : WebPart
{
protected override void LoadViewState(object savedState)
{
object obj = ViewState["TextType"];
if (obj != null)
{
PostCacheSubstitutionTextType textType = (PostCacheSubstitutionTextType)obj;
}
base.LoadViewState(savedState);
}
}

VB.NET Code Example

Public Class [MyClass]
Inherits WebPart
Protected Overloads Overrides Sub LoadViewState(ByVal savedState As Object)
Dim obj As Object = ViewState("TextType")
If obj IsNot Nothing Then
Dim textType As PostCacheSubstitutionTextType = DirectCast(obj, PostCacheSubstitutionTextType)
End If
MyBase.LoadViewState(savedState)
End Sub
End Class



Tags :

Page view tracker