SharePoint [ecmascript object model series]-03. How to view all methods of SP object)

Source: Internet
Author: User

When developing applications using the ecmascript object model, we do not consciously want to know what methods a certain SP object provides? Here we will look at how to do it.
1. Add a visual webpart (named wplkecmascript) and a Javascript file (named ecmaoplistitems. JS) to the SharePoint project we created earlier)
The code for ecmaoplistitems. JS is as follows. This code is used in the previous introduction to extract website attributes.

// Retrive website Properties
VaR siteurl = '/';

Function retrivewebsiteproperties (){
VaR clientcontext = new sp. clientcontext (siteurl );
// Var clientcontext = new sp. clientcontext. get_current ();
This. owebsite = clientcontext. get_web ();

Clientcontext. Load (this. owebsite, 'title', 'created '); // load the specific properties of website object
Clientcontext.exe cutequeryasync (function. createdelegate (this, this. onquerysucceededproperties ),
Function. createdelegate (this, this. onqueryfailedproperties ));
}

Function onquerysucceededproperties (sender, argS ){
Alert ('title: '+ this. owebsite. get_title () + 'created:' + this. owebsite. get_created ());
// Alert ('title ');
}

Function onqueryfailedproperties (sender, argS ){
Alert ('request failed. '+ args. get_message () +' \ n' + args. get_stacktrace ());
// Alert ('failed ');
}

 

Register the ecmaoplistitems. js we added above in wplkecmascript's wplkecmascript. cs. The Code is as follows:

Using system;
Using system. componentmodel;
Using system. Web;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using Microsoft. SharePoint;
Using Microsoft. Sharepoint. webcontrols;

Namespace jsomtest. wplkecmascript
{
[Toolboxitemattribute (false)]
Public class wplkecmascript: webpart
{
// Visual Studio might automatically update this path when you change the Visual Web Part project item.
Private const string _ ascxpath = @"~ /_ Controltemplates/jsomtest/wplkecmascript/wplkecmascriptusercontrol. ascx ";

Protected override void createchildcontrols ()
{
Control control = page. loadcontrol (_ ascxpath );
Controls. Add (control );
Scriptlink. Register (this. Page, "/_ layouts/jsomtest/ecmaoplistitems. js", true );
}
}
}

The wplkecmascript interface adds a button to activate the above function. The Code is as follows:

<Br/>
<Input id = "btnretrievewebsiteproperties" type = "button" value = "retrievewebsiteproperties"
Onclick = 'retrivewebsiteproperties () '/>

Project:

 

2. Add the developed visual webpart to the SharePoint website and run the SharePoint application. When the application interface is displayed, as shown in

 

3. Call the Developer Tools tool of IE as follows:

 

4. Select the script page of developer tools.


5. Select the Javascript file you want to debug. Here we want to debug ecmaoplistitems. JS, so select it.

6. Set the breakpoint in the commit Crip code, select start debugging on Developer Tools, and run the function buttons on our webpage.

 

 

 

7. Select the objects we are interested in at the breakpoint and view their methods.


 

 

Reprinted: http://www.cnblogs.com/wsdj-ITtech/archive/2012/05/08/2415303.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.