2-12 SharePoint 应用程序也 Application Pages
新建应用程序页(自动回到
layouts 下application page文件夹下)
新建空元素,用于绑定菜单,指定该应用程序页


<?xml version="1.0" encoding="utf-8"?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <CustomAction Id="MyTopMenuLink" Location="Microsoft.SharePoint.StandardMenu" GroupId="SiteActions" Sequence="0" Title="清空列表项"> <UrlAction Url="/sites/topsite/_layouts/15/CustomApplicationPage/DemoApplicationPage.aspx"/> </CustomAction> </Elements>
using System; using Microsoft.SharePoint; using Microsoft.SharePoint.WebControls; namespace CustomApplicationPage.Layouts.CustomApplicationPage { public partial class DemoApplicationPage : LayoutsPageBase { protected void Page_Load(object sender, EventArgs e) { using (SPSite site = new SPSite(SPContext.Current.Site.ID)) { using (SPWeb web = site.OpenWeb(SPContext.Current.Web.ID)) { SPListCollection listcol = web.Lists; foreach (SPList list in listcol) { System.Web.UI.WebControls.ListItem listitem = new System.Web.UI.WebControls.ListItem(list.Title); DropDownList1.Items.Add(listitem); } } } } protected void Button2_Click(object sender, EventArgs e) { using (SPSite site = new SPSite(SPContext.Current.Site.ID)) { using (SPWeb web = site.OpenWeb(SPContext.Current.Web.ID)) { SPList list = web.Lists[DropDownList1.SelectedItem.Text]; SPListItemCollection items = list.Items; foreach (SPListItem item in items) { list.GetItemById(item.ID).Delete(); } } } } } }


浙公网安备 33010602011771号