.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

read and print sharepoint list information using javascript

Posted By:      Posted Date: October 10, 2010    Points: 0   Category :ASP.Net


i am working on a form right now, user's inputs will be stored in a sharepoint list. after user click submit, it will display a thankyou panel, and send a email to me showing user's input. on the thankyou panel, there is a button, if user click it, it will open a new window and display exactly the same thing in email, so that user can check if they input the right thing.

i did this part using javascript, the window.open method. and i wrote html code in it, using window.document.write method.

i wrote a read from sharepoint list function, i dont know if it is working, but my question is how can i call this function in javascript since it will be a client side programming.

my readfromlist code is here:

public void readFromList()
             SPSite oSiteCollection = SPContext.Current.Site;
             SPList oList = oSiteCollection.AllWebs["something"].Lists["somelist"];
             SPView oListView = oList.Views["All Items"];
             SPListItemCollection collectListItems = oList.GetItems(oListView);

             foreach (SPListItem oListItem in collectListItems)
                 txtFirstName.Text = SPEncode.HtmlEncode(oListItem["First Name"].ToString()) + "<BR>";

View Complete Post

More Related Resource Links

How to read a column of a sharepoint list to a text string field of infopath form?

My infopath form used to read these email addresses from a web service and web.config file. Now i would like to get these user email addresses from a contact list in a sharepoint server. I am trying to do this without writing any codes. Here is what i have done so far: 1. Adding a new "data connection to receive data from SharePoint library or List" where i selected Email Address column of the contact list. 2. I added a new Text Field and define a new rule with "Query using a data connection" defined above. When i try to access the newly created Text field above it always return empty as if the Query attached to it did not executed at all. What did i do wrong? Is there a better way? Thank you in advance for your help.

Update SharePoint List item using UpdateListItem web service with javascript

I'm using the Custom_AddListMenuItems function in a CEWP to add a menu item to each list item to Archive that item. This is achieved by updating a choice field in the item to 'Archived'. I'm trying to do this using the web service UpdateListItem web service to update the item using Javascript, but I can not find the correct code that updates the list item. I'm using this code:     var ctx=currentCtx;     var ciid=currentItemID;     var xmlHttp=null;     if (confirm("Are you sure you want to Archive this item?"))     {         var soapRequest = '<?xml version="1.0" encoding="utf-8"?>'+             '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'+             '    <soap:Body>'+             '        <UpdateListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">'+         

Read data from BLOB field and write to sharepoint list

Hi, I want to read the data from BLOB field and write it into sharepoint list item. Please provide some pointer to archive above objective.   Thanks in Advance.

Read list of a sharepoint site

I have to read a list of a sharepoint site from a client who does not has sharepoint installed. The problem is that when I try to use the SPSite tell me http://Sharepoint/sites/Sitio2/default.aspx could not be found. Tks!!!

Error creating Read Item or Read List operation in Sharepoint Designer 2010

In terms of high-level requirements, I need to pull in lists from a couple of different web apps.  To do this, I’m using SPD 2010 to create an External Content Type for the list of interest.  I’m able to create a SOAP Service or WCF Service connection just fine.  However, when I try to create the external content type and create a Read Item Operation on one of the GetList or any other Get* (or other Update methods for that matter) methods, I get the following error:"The method that your operation is based on has parameters with complex types that do not have default parameterless constructor.  This kind of data source methods cannot be used in Business Data Catalog."I tried defining an operation on the “AddAttachment” method, and that worked just fine.  I also tried providing default values to the listName and viewName parameters when creating the SOAP Service connection, but still get the error.  Same issue with a WCF Service connection as well. Does anyone know if this is a 2010 issue, or am I approaching this requirement incorrectly?  What are other approaches for connecting to lists that reside in a different web app than yours? 

How to read Email Received to a SharePoint List

I have a email enabled Sharepoint list which can receive email. i am trying to write an evenhandler for the spemailreceiver class where i have to read the Email Body Content and grab some elements from that email body not the whole Body Content and add it to the List Field. IF the Body Content is : Name: John LastName:Johny i have to read John and Johny and populate it to a Neew List item with their fields Name= John and LastName= Johny. any ideas of reading the email body and grabbing the needed elements from it.....

Add items to sharepoint custom list using javascript with webservices



Here is the code snippet i was trying to insert item to sharepoint list but i conn't please help me what is wrong in my code and modify it.


function addlistitem(item)


var xmldoc;

var batch;

var FeedbackHTTP;

var ListName = 'Suggestions';

//The batch variable builds up the XML that we are going to submit to the SharePoint list via the SharePoint web service

batch = "<batch><method id='1' cmd='New'><field name='Title'>" + item + "</field></method></batch>";

xmldoc = '<?xml version="1.0" encoding="utf-8"?><soap:envelope xsi="http://www.w3.org/2001/XMLSchema-instance" xsd="http://www.w3.org/2001/XMLSchema" soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:body><updatelistitems xmlns="http://schemas.microsoft.com/sharepoint/soap/">'

xmldoc = xmldoc + '<listname>' + ListName + '</listname>';



xmldoc = xmldoc + '<updates>' + batch + '</updates></updatelistitems></soap:Body></soap:Envelope>';

FeedbackHTTP = new ActiveXObject("MSXML2.XMLHTTP.3.0");


Item update in the sharepoint list using web service with javascript



I am using below code for web services with javascript


function CreateListItem(Title)



    var soap1 = createEnvelope(Title);


    var ws = new ActiveXObject("Microsoft.XMLHTTP");    

      if(ws == null) 

       return null;





    ws.setRequestHeader("Content-Type", "text/xml; charset=utf-8");            







  function createEnvelope(Title)


     var batch;

var xmldoc;    

var ListName = 'S

How to prepopulate information from sharepoint list to a web form



i was working on a registration form which requires user information and save it to the sharepoint list. i was wondering if im able to search on the list item according to user's login information, and prepopulate it if information is matched. i did the search part by using query, for example, the first name:

SPList IsExist;   

   IsExist = SPContext.Current.Web.Lists["TTCVIP"];

   SPQuery query = new SPQuery();   

   query.Query = buildQuery();//search for first name = loggin name   

   SPListItemCollection found = IsExist.GetItems(query);

   //if yes, prepopulate the form

   if (found.Count > 0)

//if no, prepopulate user information from profile manager 


i then want to pull the information out from the list and prepopulate to the form. after submit the form, there is button, so when user click submit, it will show the inforamtion he has input(also need to pull info from list), i did this part by using the following code:

public void readFromList()
       SPSite oSiteCollection = SPContext.Current.Site;
       SPList oList = oSiteCollection.AllWebs["/en/admin"].Lists["TTCVIP"];
       SPView oListView = oList.Views["All Items"];
       SPListItemCollection collectListItems = oList.GetItems(oListView);     

       foreach (SPListItem oListItem

On excel sheet upload read the workbook and populate data to sharepoint list


Requirement in my current project:
In a document library when I upload an excel sheet, a specific workbook has to be read and the contents have to be uploaded to a sharepoint custom list.
The approach followed was create an event receiver and register as a feature. Following is the code for event receiver.

public override void ItemAdded(SPItemEventProperties properties)
            var list = getSPList("{150301BF-D0BD-452C-90D7-2D6CD082A247}");          
            SPListItem doc = properties.ListItem;
            doc["Msg"] = "items deleted from req list";
            string excelname=doc.File.Name;

How to prepopulate information from sharepoint list to a web form


hi all,

i was wondering if there is a way to prepopulate sharepoint list item values into a webform fields if the loggin user's information is matched with the information in the list item.

what i have done is that i made a query function to determine if info is matched, and then i try to pull some infomation out from list item. this method works fine for printing these values to some labels on the form, however, it is not working for prepopulation, which happens in the page_load function.

here is my query code:

  1.   SPList IsExist;
  2.    IsExist = SPContext.Current.Web.Lists["TTCVIP"];   
  4.    SPQuery query = new SPQuery();      
  6.    query.Query = buildQuery();//search for first name = loggin name      
  8.    SPListItemCollection

How to read a NULL value sharepoint list item


hi guys,

im having trouble pulling some specific information out from sharepoint list item. im doing a asp.net form and saved all user inputs into sharepoint list. if all information are there, my code works fine, if some colume is missing(the scenera requires to do that), it will return a  System.NullReferenceException: Object reference not set to an instance of an object exception. How can i read a null item, and maybe simply assign it to a string such as "NO VALUE", something like that?

i've tried all methods that i can think about, such as system.DBNull.value, or string.empty, or just null.

code is here: this is the save to list code:

private void SaveToTTCVIPList(SPWeb web)
        TTCVIPList = web.Lists["TTCVIP"];
        TTCVIPList = AddList(web, "TTCVIP", "List for TTCVIP user's information", "Custom List", true);
      SPListItem item = TTCVIPList.Items.Add();      
if (this.txtJointHolderName.Text == System.DBNull.Value)
        item["Joint Holder Name"] = string.Empty;

sharepoint 2010 user information list custom property



i added a custom property to the user list and wish to display it. when i go to "user info list" > "list settings" > "edit view" i see 39 properties to choose from. how can i remove these default values and add my own properties to the view.




How to read sharepoint list attributes?


Hi, I need to fetch the attributes of a specific list from sharepoint using C#.

using(SPSite site = new SPSite("http://sharepointsite/"))
    using(SPWeb web = site.OpenWeb())
       SPListCollection listCollection = web.Lists;
       foreach (SPList list in listCollection)

The above code fetch me the sharepoint lists.

Now my requirement is, to fetch the attributes of specific list. For example, "Tasks" is a list and when we create a new task, it will ask various attributes such as, "Title, priority, assigned to, status, description etc". I need to get this list of attributes and update the property grid with these attributes. How can I achieve this?


How to read value of Column under list using Sharepoint 2007



I am new to Sharepoint so please bear with me even if i ask for small clarifications.

I want to read the List using Powershell from Sharepoint Site.

Output i want to display is all columns that are under the Sharepoint List.


I have created a Sharepoint Web Application, Then i created the Sharepoint site Collection, then i created a new List named Employee List under Site Collection.

The Columns under that List are:

Empno,Empname and Salary.

I want to display the value of all the columns using the Powershell Script.

I am using the below Script.

 $list=$OpenWeb1.Lists["Employee List"]
 if($test -eq $null)
 Write-Host Site does not exist
 for($l=$listItemsTotal-1;$l -ge 0;$l--)
 Write-Host $listItems[$l].name

How to get more information about the exceptions that can happen in SharePoint 2010 projects?

In case there is an exception anywhere in the SharePoint 2010 project (most common place an exception would happen is during deployment of your SharePoint project, custom deployment configuration or custom deployment steps), there's a registry key EnableDiagnostics available for you to use.

Ready made List Types provided by SharePoint

SharePoint provides some out of the box List Types. Some of the most used ready made list types that SharePoint provides currently are listed below:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend