I have a user control, which contains another user control. The code behind of the outer control looks like this:
[PartialCaching(60,null,null,null,null,true)]
public partial class MyControl : UserControl
{
public bool PropertyOne
{
get { return AnotherUserControl.PropertyOne; }
set { AnotherUserControl.PropertyOne = value; }
}
public bool PropertyTwo
{
get { return AnotherUserControl.PropertyTwo; }
set { AnotherUserControl.PropertyTwo= value; }
}
public override void OnInit(object sender, EventArgs e)
{
CachePolicy.VaryByControl =
typeof(MyControl).FullName + ".PropertyOne;"
+ typeof(MyControl).FullName + ".PropertyTwo";
base.OnInit(sender, e);
}
}
I am trying to have it so that it caches different instances depending on the values of PropertyOne and PropertyTwo.
So in the following example, there should be three cached instances (the last control should reuse the cached instance):
<me:MyControl PropertyOne="true" PropertyTwo="true" runat="server" ID="c1" />
<me:MyControl PropertyOne="false" PropertyTwo="true" runat="server" ID="c2" />
<me:MyControl PropertyOne="true" PropertyTwo="false" runat="server" ID="c2" />
<me:MyControl PropertyOne="true" PropertyTwo="false" runat="server" ID="c2" />
But no matter what I do, I can't get it to work. ASP .NET just doesn't behave. Sometimes it seems to use the cached versions of controls, other times it just reloads the entire control, and other times it uses the wrong cached instance.
Help?