0

is there any way to connect a SharePoint application page to a list in the SharePoint to save data inside form (in application page) to the list in the SharePoint i need to know it i can make connection code in the application page to connect to the list or if there is another way to do that

this is my code

    <asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<input type="text" id="txta"/> <input type="text" id="txtb" /> 
<textarea id="txtarea" cols="10" rows="2">Text area</textarea> 
<input type="submit" /> </form>
 </asp:Content>
 <asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server"> Application Page </asp:Content>

i need to write a code to add the information in this form ,when user insert his information and click submit data sent to share point list

4

1 回答 1

0

首先,我会将您的表单输入更新为服务器控件,以便您可以从代码隐藏文件中轻松引用它们。然后在您后面的代码中,您将使用以下代码:

using (SPSite oSiteCollection = new SPSite("http://Site_Name"))
{
    using (SPWeb oWebsiteRoot = oSiteCollection.OpenWeb("/"))
    {
        SPList oList = oWebsiteRoot.Lists["Tasks"];

        SPListItem oListItem = oList.Items.Add();
        oListItem["Title"] = txtArea.Text;
        oListItem.Update();
    }
}
于 2012-06-27T21:20:47.463 回答