I am attempting to modify the properties of another webpart when my webpart's button is clicked. The code compiles and runs, and stepping through it shows that the properties do change. However, they don't stay changed. This example attempts to toggle the visibility state, but other properties won't stay changed either. Any help is appreciated.
// get the site in this context
using (SPSite SiteCollection = new SPSite(mySiteGuid))
// get the web in this context
SPWeb myWeb = SiteCollection.OpenWeb(myWebGuid);
myWeb .AllowUnsafeUpdates = true;
//ÃÂ Hide/displayÃÂ another webpart.
Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager mgr = null;
mgr = myWeb.GetLimitedWebPartManager(
foreach (System.Web.UI.WebControls.WebParts.WebPart myWebPart in mgr.WebParts)
//ÃÂ If this is the webpart we want to modify...
if (myWebPart.Title == "Other Webpart Name")
//ÃÂ Toggle the visibility state.
myWebPart.Visible = ! myWebPart.Visible;
View Complete Post