SharePoint 2013 - SPLessons

Programmatically Save the items into SharePoint List using SPServices

Home > > Tutorial
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

Programmatically Save the items into SharePoint List using SPServices

Programmatically Save the items into the SharePoint List using SpServices

Description:

Hello Every One, Today am going to see how to  Programmatically Save the items into SharePoint List using SPServices. For this code we have to  include Jquery mini file and SPServices file The Bellow code is  Client  side(Spservices) [javascript] function BtnSaveClick(){ try { var FirstName= $("#txtfirstname").val(); var LastName=$("#txtlastname").val(); var Lacation=$("#txtlocation").val(); $().SPServices({ operation: "UpdateListItems", async: false, batchCmd: "New", listName: "Registration", valuepairs: [["col_FirstName",FirstName],["col_LastName",LastName],["col_location",Lacation]], completefunc: function (xData, Status) { alert("Succefuly save items"); window.frameElement.commitPopup(); } }); } catch (e) { alert('error:' + e.Message); } } [/javascript] Here col_FirstName,col_LastName and col_loaction  are created  list columns . The Bellow Code is Html  [html] <div class="innercontent2"> <div class="Outer"> <asp:Label ID="LblFirstname" runat="server" Text="First Name"></asp:Label> </div> <div> <asp:TextBox ID="txtfirstname" runat="server"></asp:TextBox> </div> </div> <div class="innercontent2"> <div class="Outer"> <asp:Label ID="LblLastname" runat="server" Text="Last Name"></asp:Label> </div> <div> <asp:TextBox ID="txtlastname" runat="server"></asp:TextBox> </div> </div> <div class="innercontent2"> <div class="Outer"> <asp:Label ID="Lbllocation" runat="server" Text="Lacation"></asp:Label> </div> <div> <asp:TextBox ID="txtlocation" runat="server"></asp:TextBox> </div> </div> <div class="innercontent2"> <div> <asp:Button ID="BtnUpload" CssClass="btn_class" runat="server" Text="Save" OnClientClick="return BtnSaveClick();" /> </div> </div> [/html]