Sunday, July 22, 2012

How to get java script variable value on server side

The answer is Hidden field or any input control.

You just need to take hidden field and set the value of  java script variable on hidden filed .like below

var javascriptvariable='some value'; 
Now on server side you can get the hidden field which is 
actually java script variable  value 
String hdnvalue=hiddenfield.value;
I have used Jquery val function to set the value .
 You can use val function of jquery  in
two ways to get the value just use the 
and for setting the value you need to pass 
the value as argument in val function 
like this 
 alert($('#hiddenfield').val() );
you can check live demo here .
 I love  for jquery code sharing.  

No comments:

Post a Comment