0

I have a custom EDIT/NEW/View forms for a content type.

i need to change the properties programmatically since i have over 1000sites using these forms

        static void Main(string[] args)
    {
        using (SPSite site = new SPSite("http://v058mosffe008:8080/sites/pmo"))  // e.g. http://server/sites/asite
        using (SPWeb web = site.OpenWeb("afspmo"))
        using (SPWeb subweb = web.Webs["projecttemplate"])
        {  
            SPFile fileT = subweb.GetFile("Lists/Quality Gate Checklist/InitiateNewForm.aspx");   // e.g. /sites/asite/default.aspx
            SPLimitedWebPartManager lwpm = fileT.GetLimitedWebPartManager(System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
            SPLimitedWebPartCollection webParts = lwpm.WebParts;
            foreach(WebPart webpart in webParts){
                if (webpart.Title == "QA Checklist (1)")
                {
                    FileStream stream = new FileStream("C:\\file.txt", FileMode.Open);
                    StreamReader reader = new StreamReader(stream);
                    string xsl = reader.ReadToEnd();
                    DataFormWebPart dvWebpart = (DataFormWebPart)webpart;
                    string preXSL = dvWebpart.Xsl;
                    dvWebpart.Title = "QA Checklist (1)";
                    dvWebpart.Xsl = xsl;
                    lwpm.SaveChanges(dvWebpart);
                    fileT.Update();
                    subweb.Update();
                }
            }
        }
    }

when i run this code, i see that it has updated the webpart in code, but the changes dont reflect when i navigate to the page. it seems to be some sort of caching, any ideas

4
  • Hi, did you try to flush object cache in Site Actions->Site settings -> Object cache? Apr 9, 2013 at 9:56
  • i cant find that setting, using sharepoint 2007 Apr 9, 2013 at 10:25
  • Site Actions->Site Settings (root) -> Site Collection Administration section -> Site collection object cache. I have this one Apr 9, 2013 at 12:02
  • so i couldn't find the setting because, publishing features wasn't active. i ran my tests again the flushed the object cache. the web part was still the same. but interestingly the xsl in web part properties was correct Apr 9, 2013 at 14:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.