判断webpart类型 How can I tell what type a web part is?
using(new SPSite("http://mysite/myweb").OpenWeb())
{
//give relative path of the webpartpage
SPLimitedWebPartManager wm = page.GetLimitedWebPartManager("default.aspx",
System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
foreach (System.Web.UI.WebControls.WebParts.WebPart wp in wm.WebParts)
{
}
}
if (wp.GetType().ToString() == "Microsoft.SharePoint.WebPartPages.SPUserCodeWebPart")
额,那你属性所有webpart的特点,争取一眼看出来
You can add
?contents=1
to the end of your page's URL to get a nice neat list of all the webparts that are currently opened and closed: http://sharepointsolutions.blogspot.com/2008/04/when-good-web-parts-go-bad.html