2013-06-18 76 views
1

我正在爲SharePoint 2013開發Apps。我想在我的應用程序包中編程創建多個列表
它就像用戶輸入列表的名稱,當他點擊創建按鈕時,應該在我的應用程序中創建具有相同名稱的列表,而不是在SharePoint網站中創建。如何在SharePoint 2013應用程序中創建列表?

我創建了一個AutoHosted App,其中我使用了客戶端對象模型技術。

如何實現此功能?

+0

我已經創建了使用客戶端對象模型的列表。但是所有列表都是在SharePoint網站中創建的。 –

回答

1

我已經找到了解決辦法。
當我創建ContextToken對象時,我通過了請求的SPHostUrl,但是我通過了SPAppWebUrl因此,它使用它獲取AppWebUrl的標記,因此它在我的應用程序中創建了列表,而不是在SharePoint網站中。

像婁代碼:

var hostWeb = Page.Request["SPAppWebUrl"]; //This will get the URL of AppWeb not SharePoint site... 

using (var clientContext = TokenHelper.GetClientContextWithContextToken(hostWeb, ContextToken, Request.Url.Authority)) 
{ 
    //Code for creating list or manipulating them... 
    //This ClientContext is created for the AppWeb. 
} 

當我創造我每次被找到hostWeb對象是使用SPHostUrl創建時間搜索代碼,所以我問這個問題。
謝謝大家的幫助。

相關問題