1. use vs2010 add new empty sharepoint project.

2.add application

3.add js as below: 

 

 

<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>

<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>

<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>

<%@ Import Namespace="Microsoft.SharePoint" %>

<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ApplicationPage1.aspx.cs" Inherits="SharePointProject2.Layouts.SharePointProject2.ApplicationPage1" DynamicMasterPageFile="~masterurl/default.master" %>

<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">

<script type="text/ecmascript" src="/_layouts/SP.Core.js" />

<script type="text/ecmascript" src="/_layouts/SP.Debug.js" />

<script type="text/ecmascript" src="/_layouts/SP.Runtime.Debug.js" />

<script type="text/javascript">

var clientContext = null;

var web = null;

ExecuteOrDelayUntilScriptLoaded(Initialize, "sp.js");

function Initialize() {

clientContext = new SP.ClientContext.get_current();

web = clientContext.get_web();

var itemCreateInfo = new SP.ListItemCreationInformation();

var listCreationInfo = new SP.ListCreationInformation();

listCreationInfo.set_title('My Custom Generic List');

listCreationInfo.set_templateType(SP.ListTemplateType.genericList);

this.oList = web.get_lists().add(listCreationInfo);

clientContext.load(oList, 'Title', 'Id');

clientContext.executeQueryAsync(Function.createDelegate(this, this.onListCreateSuccess),

Function.createDelegate(this, this.onQueryFailed));

}

function onListCreateSuccess(sender, args) {

alert("List title : " + this.oList.get_title() + "; List ID : " + this.oList.get_id());

}

function onQueryFailed(sender, args) {

alert('request failed ' + args.get_message() + '\n' + args.get_stackTrace());

}</script>

</asp:Content>

posted on 2010-06-29 15:06  blogsweb  阅读(184)  评论(0)    收藏  举报