You can do that by exposing the data via a web service
[ScriptService] public class SimpleWebService : System.Web.Services.WebService{
[WebMethod]
public string EchoInput(String input)
{
// Method code goes here.
}}
And can then add it into your asp.net page like so
<asp:ScriptManager runat="server" ID="scriptManager"> <Services> <asp:ServiceReference
path="~/WebServices/SimpleWebService.asmx" /> </Services></asp:ScriptManager>
To call the javascript
// This function calls the Web Service method.
function EchoUserInput()
{
var echoElem = document.getElementById("EnteredValue");
Samples.AspNet.SimpleWebService.EchoInput(echoElem.value,
SucceededCallback);
}
// This is the callback function that
// processes the Web Service return value.
function SucceededCallback(result)
{
var RsltElem = document.getElementById("Results");
RsltElem.innerHTML = result;
}
There it is, easy as. Check more details at ASP.Net