Introduction
 
 In this article we will get to know how to get and set values from the property  bag in SharePoint 2013. 
 
 What is property bag
 
 The Property Bag is a kind of hash table that can store any metadata as  Key-Value pairs at site level. Examples of values that can be stored are  connection strings, server names, file paths, and other settings needed by the  SharePoint application. Most of the time we will store the above settings in  configuration file, which is common to the entire web application. If there is  any setting specific each and individual sites in the web application, then we can use the SharePoint Property Bag.
 
 How to get the property bag
 
 The property bag can be found by following the below steps:
  	- Open SharePoint Designer 2013 – open the particular site. 
 
 
- In the ribbon you will see the “Site Options” clicking on which  	you can add new/modify key-value pairs
 
 ![Site Options]() 
 
 We will now see how to set and get new values into the Property Bag.  	Follow the below steps for the same.
Steps
  	- Open Visual Studio & create a new SharePoint App Project.
 
 ![App in SharePoint]() 
 
 
- Select the Host for the app as “SharePoint-Hosted”. 
 
 
- Once the project is created, you will find the following structure.
 
 ![TestApp]() 
 
 
- Add a save button to the default.aspx page as below:
 - <asp:Buttonrunat="server"ID="btnSave"OnClientClick="btnSaveClick()"Text="Save"/>  
 
- Add the following code to App.js file,
 - 'use strict';  
- var appWebContext;  
- var listResult;  
- var hostweburl;  
- var webProperties;  
- function btnSaveClick()  
- {  
-     appWebContext = newSP.ClientContext.get_current();  
-     hostweburl = decodeURIComponent($.getUrlVar("SPHostUrl"));  
-     varhostwebContext = newSP.AppContextSite(appWebContext, hostweburl);  
-     var web = hostwebContext.get_web();  
-     appWebContext.load(web);  
-     webProperties = web.get_allProperties();  
-     appWebContext.load(webProperties);  
-     webProperties.set_item("StringConnection", true);  
-     web.update();  
-     appWebContext.executeQueryAsync(onQuerySucceeded, onQueryFailed);  
- }  
- functionon QuerySucceeded()  
- {  
-     varpropertyValue = webProperties.get_fieldValues().StringConnection;  
-     alert(propertyValue);  
- }  
- functionon QueryFailed(sender, args)  
-     {  
-         alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());  
-     }  
-       
- jQuery.extend(  
- {  
-     getUrlVars: function ()  
-     {  
-         varvars = [], hash;  
-         var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');  
-         for (vari = 0; i < hashes.length; i++)  
-         {  
-             hash = hashes[i].split('=');  
-             vars.push(hash[0]);  
-             vars[hash[0]] = hash[1];  
-         }  
-         returnvars;  
-     },  
-     getUrlVar: function (name)  
-     {  
-         returnjQuery.getUrlVars()[name];  
-     }  
- });  
 
- Go to AppManifest.xml a Permissions tab. We need to give permission to  	the app to access the host web. Select “SiteCollection” Permission  	Level ”Manage”.
 
 
- Deploy the solution, Trust the app.
 
 
- Once the page opens, click on the Save Button, an Alert will be coming  	up with the value as “TRUE”.
 
 
- Check in the SharePoint designer if a key called “String Connection”  	has been set as “TRUE”.
 
 ![String Connection]()