Have Hidden field control
<asp:HiddenField id="fileId" runat="server" value='Nishant' />
JavaScript Code which will return hidden field Value
document.getElementById("<%= fileId.ClientID %>").value;
Note You can also make ClientIDMode="Static"
use this property for your control and retrieve it by id itself 'fileId' ForInstance:
<asp:HiddenField id="fileId" runat="server" ClientIDMode="Static" value='Nishant' />
and use JavaScript code:
document.getElementById("fileId").value;
It will also return Nishant but Id will be static. Use only ClientIDMode="Static
when you are sure that no one control has same Id.
Runnable Asp.Net Code http://runnable.com/UjsLAmP-yM0VAADp/asp-net-how-to-get-server-control-value-in-javascript