我通過構建一個WCF服務來完成這個工作,
的GUID是jQuery的Ajax調用,當web部件最小
公共字符串UpdateCurrentWebPart(字符串guidString)通過了該網頁組件的客戶端ID {
SPWeb myweb = SPContext.Current.Web;
myweb.AllowUnsafeUpdates = true;
//only want the webparts with have personal settings
using (SPLimitedWebPartManager mgr = myweb.GetLimitedWebPartManager("pages/default.aspx", PersonalizationScope.User))
{
string result = "Not found " + guidString;
//find my webpart
foreach (System.Web.UI.WebControls.WebParts.WebPart _webpart in mgr.WebParts)
{
if (guidString.Contains(_webpart.ClientID))
{
try
{
//toggle it
if (_webpart.ChromeState == PartChromeState.Minimized)
{
_webpart.ChromeState = PartChromeState.Normal;
}
else
{
_webpart.ChromeState = PartChromeState.Minimized;
}
//save it
mgr.SaveChanges(_webpart);
//useful for debugging
result = guidString + _webpart.ChromeState.ToString();
}
catch
{
}
}
}
return result;
}
來源
2011-04-27 13:05:41
ben
這似乎是... 。 什麼?如果有一個開箱即用的功能,我會說使用它。否則,WCF是一個易於部署的解決方案。 – Colin 2011-04-18 12:34:43