Monday, 21 July 2014

SharePoint App Access App properties

Open your App Part from Solution explorer
Add Client Web part (Host web)..if you don't added to solution
Go to "Element.xml" under client web part
You will see Properties Inside Properties,
add one or two properties..
<Property Name="EnumProperty1" Type="enum" WebBrowsable="true" WebDisplayName="Enum Property" WebDescription="Description for Enum Property" WebCategory="SharepointFrontier Properties" DefaultValue="Ind" RequiresDesignerPermission="true">
<EnumItems>
<EnumItem Value="US" WebDisplayName="United States of America"/>
<EnumItem Value="Uk" WebDisplayName="United Kingdom"/>
<EnumItem Value="Ind" WebDisplayName="India"/>
</EnumItems>
</Property>
or
<Property Name="BooleanProperty1" Type="boolean" WebBrowsable="true" WebDisplayName="Boolean Property" WebDescription="Description for Boolean Property" WebCategory="SharepointFrontier Properties" DefaultValue="true" RequiresDesignerPermission="true"/>
view raw gistfile1.xml hosted with ❤ by GitHub
Save
 If you want to access these propreties in the Host page load..use below code in page load
var queryStringValue = getQuerystring('EnumProperty1');
alert(queryStringValue);
var queryStringValue1 = getQuerystring('BooleanProperty1');
alert(queryStringValue1);
function getQuerystring(key) {
key = key.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regex = new RegExp("[\\?&]" + key + "=([^&#]*)");
var qs = regex.exec(window.location.href);
if (qs == null)
return null;
else
return qs[1];
}
view raw gistfile1.js hosted with ❤ by GitHub