რამოდენიმე დღის წინ მქონდა ესეთი შემთხვევა, რომ შეარპოინტის გვერდზე დავამატე ვებ-ფართი - "Content Editor Web Part".
ალბად იცით რომ ამ ვებ-ფართით ბევრი რამის გაკეთება შეიძლება შეარპოინტზე.
თუნდაც ფლეშ-ვიდეოს დადება .
მეც ვიდეოს დადება მინდოდა და კოდში მივუთითე არ არსებული ვიდეოს მისამართი და გამოშტერდა, გვერდი აღარ იტვირთებოდა ბოლომდე, ჩერდებოდა ვიდეოს ჩატვირთვაზე, ამ შემთხვევაში საკმაოდ კარგი გამოსავალი არის პროგრამირებით ამ ვებ-ფართის ამოშლა ვებ-გვერდიდან.
კოდი ქვემოთ იხილეთ:
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebPartPages;
namespace WebPartDeleter
{
class Program
{
static void Main(string[] args)
{
string mossURL = "http://wss/sites/sample/devlearning/";
string mossURL = "http://wss/sites/sample/devlearning/";
/// Declare new SPSite object and set URL
SPSite wss = new SPSite(mossURL);
/// Declare new SPWeb object
SPWeb web = wss.OpenWeb();
/// Declare new SPWebPartCollection and set WebParts
/// Also we can use SPLimitedWebPartCollection to do this...
SPWebPartCollection webParts = null;
webParts =
web.GetWebPartCollection(mossURL,
Microsoft.SharePoint.WebPartPages.Storage.Shared);
/// and if we want to delete any web part, for example
/// WebPart, we must delete it by its StorageKey -- GUID
webParts.Delete(webParts[Web Part Index].StorageKey);
/// Display notification when finish job
Console.WriteLine("Press Enter to Exit...");
/// Wait for any key to exit
Console.ReadKey();
}
}
}
No comments:
Post a Comment