In a Visual Web Part we were saving few values in a hidden input field and were retrieving it in the jScript. However the issue we were facing was the id of the control kept changing.
Here the clientidmode property came to rescue.
<input id=”hiddenobject” type=”hidden” clientidmode=”Static” runat=”server”/>
With the clientidmode set as static the id remains the same.
Hope it helps.