开发者

Part of custom control should be rendered only once

I am working on a custom control. Part of it is to render a div that is not displayed right away. Based on a particular client event, that div is shown. Everything works fine when there is only once instance of the custom control on a page. But in case of multiple instances, that many above mentioned divs are rendered, though not displayed. To make container page lighter, I basically want to render that div only once, irrespective of the number of occurrences of the custom control. Any h开发者_Python百科elp would be great.

Thanks, Surya


Perhaps you can store a flag telling that that div has already been rendered. You can store that flag in HttpContext.Items. Here is some code

if ((bool)HttpContext.Current.Items["divRendered"] == false)
{
   //Render the div
   HttpContext.Current.Items["divRendered"] = true;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜