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];
}
Databricks Vs Synapse Spark Pools – What, When and Where?
Databricks or Synapse seems to be the question on everyone’s lips, whether its people asking
May
Power BI to Power AI – Part 2
This post is the second part of a blog series on the AI features of
Apr
Geospatial Sample architecture overview
The first blog ‘Part 1 – Introduction to Geospatial data’ gave an overview into geospatial
Apr
Data Lakehouses for Dummies
When we are thinking about data platforms, there are many different services and architectures that
Apr
Enable Smart Facility Management with Azure Digital Twins
Before I started writing this blog, I went to Google and searched for the keywords
Apr
Migrating On-Prem SSIS workload to Azure
Goal of this blog There can be scenario where organization wants to migrate there existing
Mar
Send B2B data with Azure Logic Apps and Enterprise Integration Pack
After creating an integration account that has partners and agreements, we are ready to create
Mar
Incremental Group is acquired by Telefónica Tech
Incremental’s acquisition by Telefónica Tech powers the next phase of growth for the digital technology
Mar