Hello I have an issue with debugging code of my UserControls. I am adding my UserControls dynamic to a placeHolder on a layout. After the controls have been added to the placeholder, when I have attached VS2008 to my worker process I only get to debug my code once. Normally when i refresh my page in IE / Firefox my breakpoint are hit again, but now they are not. This is some of the code used to add controls to my page:
ascx for the UserControl in which the cs adds the other UserControls dynamicly:
<asp:Repeater ID="rptListRenderer" runat="server" EnableViewState="false">
<ItemTemplate>
<asp:PlaceHolder ID="Content" runat="server" />
</ItemTemplate>
</asp:Repeater>
part of .cs of this file where I add the controls:
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
Item dataItem = (Item)e.Item.DataItem;
System.Web.UI.WebControls.PlaceHolder content = (System.Web.UI.WebControls.PlaceHolder)e.Item.FindControl("content");
if (content != null)
{
RenderingReference[] renderings = dataItem.Visualization.GetRenderings(Sitecore.Context.Device, false);
foreach (RenderingReference rendering in renderings)
{
string strDataSource = dataItem.ID.ToString();
rendering.Settings.DataSource = strDataSource;
content.Controls.Add(rendering.RenderingItem.GetControl(rendering.Settings));
}
}
}
What I have also noticed is that when I work with cookies or with dynamicly added controls inside the UserControls that are added dynamicly, I have to rebuild to see effect. For example:
I add a coo开发者_运维技巧kie with a GUID of an item which is used to determine a class on a HyperLink on a dynamicly added control. The class is only changing after a build, while I want it to change after a page refresh without building my project. Is there anyone around that had similar problems or might have a clue what can be happening here? If I need to be more specific on one of the above described things please tell me!
I have had this issue several times now. We are developing on the CMS Sitecore and Sitecore has caching options. When Caching - Vary by data is true on a Rendering that places Controls code behind, those Controls won't be reloaded but re-used. This is why the breakpoints won't be hitted.
精彩评论