1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / strange bug after updating user control

strange bug after updating user control

3 posts, 0 answered
  1. Victor
    Victor avatar
    44 posts
    Registered:
    10 Mar 2009
    09 Apr 2009
    Link to this post
    I have been creating this user controls with a generic content wrapper and other properties such as title and hyperlinks.

    Our editors have been creating pages with these controls in them. A couple days ago I updated the usercontrols with extra decorators for properties such as ImageSelector and CmsUrlWebEditor and stuff got weird.

    The first symptom is when you edit the control and click properties tab (it defaults to generic content's HtmlContentEditor) it shows you the properties but the tab itself does not highlight. When you try use any of the selectors it just switches back to HtmlContentEditor.

    I commented out decorator for HtmlContentEditor but got Object reference error when saving the control.

    Now this only happens with controls already in the pages. If I add a new one of the same type it works fine.

    From here it seems like a conflict between what the database has about the control and what reflection returns is producing unexpected behavior.

    Now, we have hundredths of them controls all over the website we are building and going to each page, delete and recreate is not an option.

    Is there a way to "clean" what the database has about these controls?

  2. Victor
    Victor avatar
    44 posts
    Registered:
    10 Mar 2009
    09 Apr 2009
    Link to this post
    Can somebody please tell me the database table(s) holding property values?

    I was able to locate all instances of the broken control in the database with the following query:

    select cl.ControlId, cp.name, cp.Value 
    from sf_cmsctrllinks cl, sf_cmscontrolproperty cp, sf_webcontrolbase wc 
    where cp.ControlID = cl.ControlID 
        and wc.ID = cl.ControlID 
        and wc.[Type]='~/MyControls/BrokenControl.ascx' 
    order by cl.ControlId, cp.name, cp.Value 
     

    Then I tried deleting all properties from one:

    delete sf_cmscontrolproperty where controlid='10d8b55c-5cc7-4347-a333-6b6f65e1515e' 

    Now when I look at live site, the control is empty but edit still shows old content.

  3. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    13 Apr 2009
    Link to this post
    Hi Victor,

    sf_CmsControlProperty table collects data about the properties that have been set to a given control. The control can be found as Id( Guid). sf_WebControlBase and sf_CmsCtrlLinks shows where the control is located - which page and placeholder.

    Have you tried to republish the pages? Thus, you will create a new version and the old content should be updated.

    Here are code samples that you can use to update the problematic control and publish all pages.

        CmsManager manager = new CmsManager(); 
        Guid controlid = new Guid("5A15D7BD-DE1B-450A-9EEA-0172E55E4F14"); 
        ICmsWebControl controlForEdit = manager.GetControl(controlid, true); 
        manager.SaveControl(controlForEdit); 

          IList listofpages = manager.GetPages(); 
            foreach (IPage page in listofpages) 
            { 
                if (page != null
                { 
                    ICmsPage pageforEdit = manager.GetPage(page.ID, trueas ICmsPage; 
                    IStagedPage staged = pageforEdit.Staged.CheckOut(); 
                    staged.CheckIn(); 
                    manager.SavePage(pageforEdit); 
                  
                } 
     
            } 


    Regards,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Register for webinar
3 posts, 0 answered