J'utilise le code suivant pour ajouter des composants WebPart à une page par programmation, Cependant, j'ai un problème qui après la publication de la page est la partie Web est non visible sur la page, je dois actualisez la page pour obtenir la partie Web visible,Ajouter un composant WebPart Programatically
appréciez votre soutien.
SPSite site = new SPSite("http://syngdcds0032:23547");
site.AllowUnsafeUpdates = true;
SPWeb web = site.OpenWeb();
web.AllowUnsafeUpdates = true;
SPList list = web.Lists["Assets"];
SPView setView = list.Views["VVV"];
// Instantiate the web part
ListViewWebPart wp = new ListViewWebPart();
wp.ZoneID = "Left";
wp.ListName = list.ID.ToString("B").ToUpper();
//wp.ViewGuid = list.DefaultView.ID.ToString("B").ToUpper();
wp.ViewGuid = setView.ID.ToString("B").ToUpper();
// Get the web part collection
SPWebPartCollection coll =
web.GetWebPartCollection("http://syngdcds0032:23547/Pages/AssetSearch1.aspx",
Storage.Shared);
// Add the web part
coll.Add(wp);