如何使用JavaScript调用C#方法. [英] How to call the C# methods with JavaScript .

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

问题描述

我只想创建一个包含一些JS代码的HTML文件..
我想让JS代码直接调用C#方法吗?

注意:它不是HTML,不是ASPX或其他东西!

解决方案

我假设您想将HTML/JavaScript托管在WebBrowser控件中.在这种假设下,这里有两个资源供您选择...

从WebBrowser控件中托管的JavaScript调用C#方法

另外,在"最完整的C#Webbrowser包装器控件"中搜索字符串"ObjectForScripting".

I just want to create a HTML file include some JS code in it ..
And I want the JS codes to call the C# methods ,any way directly ?

Notice: It is HTML not ASPX or something!

解决方案

I assume you want to host the HTML/JavaScript in a WebBrowser control. Given that assumption, here are two resources for you...

Call C# Methods From JavaScript Hosted in a WebBrowser Control

Also, search "The most complete C# Webbrowser wrapper control" for the string "ObjectForScripting".


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

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