从JavaScript调用C#函数 [英] Call C# function from JavaScript

查看:104
本文介绍了从JavaScript调用C#函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好.我正在尝试找到一种方法,可以将数组中存储的数据下载到文本文件中.我没有使用AJAX,但我正在使用HTML5.下载此文件的最佳方法是什么?我知道HTML5中提供的FileSaver API,但似乎无法使其正常工作.该解决方案需要在所有HTML5浏览器上都可以使用.

Hi there. I am trying to find a way to download the data I have stored in an array into a text file. I am not using AJAX but I am using HTML5. What would be the best way to download this file? I know of the FileSaver API provided in HTML5 but cant seem to get it to work. The solution needs to work on all HTML5 browsers.

推荐答案


您可以使用javascript的__doPostBack函数使用javascript调用c#函数.
这是使用__doPostBack函数的文章.

从JavaScript调用C#函数 [
Hi,
You can call a c# function using javascript using __doPostBack function of javascript.
Here is the article for using __doPostBack function.

Call C# function from JavaScript[^]

All the best.
--Amit


首先,您需要了解所使用的JavaScript类型.可能是JScript V8,具体取决于浏览器.其次,您必须知道您是否真的需要调用.NET.如果是IE,则说明它使用的是JScript,您可以使用旧的WinHTTP来下载文件或发出任何请求.
First of all you need to know what kind of JavaScript you are using. It could be JScript, V8, depending on the browser. Second, you have to know if you really need to call .NET. If it is IE, then it is using JScript, and you can use the old WinHTTP to download files or make any requests.


这篇关于从JavaScript调用C#函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆