Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/443.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从jstorage调用C#代码隐藏函数_C#_Javascript_Jstorage - Fatal编程技术网

从jstorage调用C#代码隐藏函数

从jstorage调用C#代码隐藏函数,c#,javascript,jstorage,C#,Javascript,Jstorage,我使用下面的代码使用jstorage存储数据。我可以;无法理解什么是从服务器()加载数据。请帮助我从jstorage调用代码隐藏函数 <script src="prototype.js"></script> <script src="jstorage.js"></script> <script> // Check if "key" exists in the storage var value = $.jStorage.get("key

我使用下面的代码使用jstorage存储数据。我可以;无法理解什么是从服务器()加载数据。请帮助我从jstorage调用代码隐藏函数

<script src="prototype.js"></script>
<script src="jstorage.js"></script>
<script>
// Check if "key" exists in the storage
var value = $.jStorage.get("key");
if(!value){
    // if not - load the data from the server
    value = "hai";
    value = load_data_from_server() //I want to call c# code behind function here
    // and save it
    $.jStorage.set("key",value);
}
</script>

//检查存储器中是否存在“密钥”
var值=$.jStorage.get(“键”);
如果(!值){
//如果没有-从服务器加载数据
value=“hai”;
value=load_data_from_server()//我想在这里调用c#代码隐藏函数
//并保存它
$.jStorage.set(“键”,值);
}

每当您想从客户端调用服务器代码时,最常见的解决方案就是使用AJAX。使用C#中的WebAPI可以非常轻松地公开该方法和各种JavaScript库,让您可以轻松调用AJAX。