Access Server side variable on client side and Vice versa Asp.Net and javascript
asp.net
Solution
You can simply write out variables to the javascript using code blocks (`<%%>`):
var mJSVariable = <%:myServerSideVariable%>;
To do the opposite, the easiest thing it to write the JS value into a server side hidden form field and pick it up on the server side:
<input type="hidden" id="myHiddenId" runat="server" />
// Javascript
var myHidden = document.getElementById("<%:myHiddenId.ClientId%>");
myHidden.value = myJSVariable;
// Code behind
var myJSVariableValue = myHiddenId.Value;
Problem
I have a requirement of adding server side variables in client side and other way round. Because I need to set a value from client side using javascript and access the same in code behind page. I have to use C#.Net and javascript. Any directions please