1

I use code below to add several "MyControl.ascx" controls to my page, I have also used outputcache direction on .ascx file.

After the controls are cached, their output html will be the same!!! How could I vary them?

Output cache direction:

<%@ OutputCache Duration="120" VaryByParam="None"  %>

C# Code:

for(int i=0;i<2;i++)
{
    Control control = Page.LoadControl("MyControl.ascx");
    control.ID = Guid.NewID().ToString();

    Page.Controls.Add(control);

    if(control is PartialCachingControl)
    {
        if(PartialCachingControl.CacheControl != null)
        {
            if(i==0)
                ((MyControl)control).style("color:yellow");
            else
                ((MyControl)control).style("color:blue");

            ((MyControl)control).setTime(DateTime.Now.ToString());
        }
    }
}
Ali. B
  • 65
  • 9

0 Answers0