Saturday, September 27, 2008

Link button to Delete Current Sharepoint Webpart

Well on my search for new stuff i found all the Sharepoint Web Part javascripts events, i say to my self, "GREAT", now can explorer that litle secrect Sharepoint Webpart have, so i make this litle script to delete current Webpart.

I found this Javascript method "MSOLayout_AddChange(WebPart,Property,NewValue)" to update propertys, greate now just use....

Delete Web Part:
Add Content Editor Web Part and select "html editor"

< script type="Text/ JavaScript" >
function RemoveWP()
{
var WPQId;
var WPObject;
var titleid;
var WPQPos;
titleid=window.event.srcElement.parentNode.id;
WPQPos=titleid.lastIndexOf("WPQ");
if (WPQPos>0)
{
WPQId='WebPart' + titleid.substring(WPQPos, titleid.length);
WPObject=document.getElementById(WPQId);
MSOLayout_RemoveWebPart(WPObject);
}
}
< / script >
< href="#" onclick="javascript:RemoveWP()">Delete Webpart< / a >
Post a Comment