If you are using the @ OutputCache directive on a user control that you are adding programatically you will not receive a reference to the control type directly when you ‘LoadControl’. Instead you will be returned an object of type PartialCachingControl.
The CachedControl property is not hugely intuitive, it’s actually set when the object is cached the first time – it’s the property saying, “By the way, I’ve cached this object for you, just so you know”. If the object is already in the cache the CachedControl property returns null, this time it’s saying, “I haven’t had to cache anything as it was already in the cache”.
If you do not add the PartialCachingControl to the control tree the CachedControl property will ALWAYS return null.
Here is a simple routine that demonstrates this:
void Page_Init()
{
Control Item;
Item = Page.LoadControl(“test1.ascx”);
Test1a.Controls.Add(Item); // Comment this line to see the “always null” behavior.
if ( ((PartialCachingControl)Item).CachedControl != null)
{
Response.Write(“CachedControl is not null! – Control was not in the cache but is now “);}
else
{
Response.Write(“CachedControl is null! – Control was already in the cache”);}
// To obtain a reference to your object access the control collection (Alternatively you can use ‘FindControl’)
MyUserControl myControl = (MyUserControl) Item.Controls[0];
}
Introduction to Data Wrangler in Microsoft Fabric
What is Data Wrangler? A key selling point of Microsoft Fabric is the Data Science
Jul
Autogen Power BI Model in Tabular Editor
In the realm of business intelligence, Power BI has emerged as a powerful tool for
Jul
Microsoft Healthcare Accelerator for Fabric
Microsoft released the Healthcare Data Solutions in Microsoft Fabric in Q1 2024. It was introduced
Jul
Unlock the Power of Colour: Make Your Power BI Reports Pop
Colour is a powerful visual tool that can enhance the appeal and readability of your
Jul
Python vs. PySpark: Navigating Data Analytics in Databricks – Part 2
Part 2: Exploring Advanced Functionalities in Databricks Welcome back to our Databricks journey! In this
May
GPT-4 with Vision vs Custom Vision in Anomaly Detection
Businesses today are generating data at an unprecedented rate. Automated processing of data is essential
May
Exploring DALL·E Capabilities
What is DALL·E? DALL·E is text-to-image generation system developed by OpenAI using deep learning methodologies.
May
Using Copilot Studio to Develop a HR Policy Bot
The next addition to Microsoft’s generative AI and large language model tools is Microsoft Copilot
Apr