1

我使用下面的代码向我的页面添加了几个“MyControl.ascx”控件,我还在 .ascx 文件上使用了输出缓存方向。

控件缓存后,它们的输出html是一样的!!!我怎么能改变它们?

输出缓存方向:

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

C#代码:

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());
        }
    }
}
4

0 回答 0