
Another way:-
In case for some reasons you don't want to have a server input control you can put the hidden field in a literal tag
<asp:literal id="literal1" runat="server"><input type="hidden" id="myhiddenField" value="{0}"/></asp:literal>
and then assign a value to the literal in codebehind like this
literal1.Text = string.Format(literal1.Text, "somevalue"); // somevlue can be your ViewState value
then access it in javascript as usual
var name = document.getElementById('myhiddenField').value;
alert(name)
Note: if you are using update panels put the hiddenfields inside the contenttemplate tag of the updatepanel
Happy Coding,
If it helps you or directs U towards the solution,
MARK IT AS ANSWERProgrammer123, if this helps please login to Mark As Answer. | Alert Moderator