SharePoint 2013 - Read web part properties with client side JavaScript.

Hello,

Sometimes we want to be able to read web part properties on our client side code, e.g. when we want to use jQuery functionality to implement certain requirements.

Easiest way to achieve this is just use the asp:HiddenField control to store the value of the property, then get the value using jQuery.

So on your html:

Then on the JavaScript section:


On your ascx code behind file, just store the value during page load:

Hope this helps,
Andreas

2 comments

Thank you, this works perfect!

Reply

if you are using a separate js file for your logic you need to use this:
"var hv = $('input[id$=hidClientField]').val();" - otherwise javascript will throw a syntax error

Reply

Post a Comment