Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

share|improve this question
    
Hi, did you try to flush object cache in Site Actions->Site settings -> Object cache? –  Andrew Adamich Apr 9 '13 at 9:56
    
i cant find that setting, using sharepoint 2007 –  Sebastien Stettler Apr 9 '13 at 10:25
    
Site Actions->Site Settings (root) -> Site Collection Administration section -> Site collection object cache. I have this one –  Andrew Adamich Apr 9 '13 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 –  Sebastien Stettler Apr 9 '13 at 14:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.