The class needs to be exposed as a web service. Then you can use JSON to access it client side
For example:
(In an ASMX file such as Address.asmx)
[ScriptService]
[WebService(Namespace = "JsonPanels.Services")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class Address : WebService {
[WebMethod]
public String LoadAddress() {
return "some values...";
} // webmethod::StoreValues
}
In the pages aspx file you will need a scriptmanager that references the web service:
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="~/Services/Address.asmx" />
</Services>
</asp:ScriptManager>
Your javascript function will look like:
<script type="text/javascript">
function callLoadAddress() {
JsonPanels.Services.Address.LoadAddress(GetLoadAddress_success, OnFailed);
}
function GetLoadAddress_success(e) {
var result = e;
$get('resultAddress').innerHTML = result;
}
// --------------------------
function OnFailed() {
$get('resultFailed').innerHTML = "failed";
}
</script>