Compile the js file into a dll for page calling. jsdll
1. Add a project in solution: JSControl
2. Add a js file (JScript1.js) to this project)
Script content:
function showAlert(){alert('Today is a good dary');}
3. Change JScript1.js attributes and Build Action to Embedded Resource (Embedded Resource)
4. Add a line to the AssemblyInfo. cs file of the JSControl project: (Note: JSControl. JScript1.js, JSControl is the namespace, and JScript1.js is the file name)
[assembly: System.Web.UI.WebResource("JSControl.JScript1.js", "application/x-javascript")]
5. Add a class for registering client scripts in the project:
namespace JSControl{public class Class1 : System.Web.UI.WebControls.WebControl{protected override void OnPreRender(EventArgs e){if (this.Page != null){ClientScriptManager manager = this.Page.ClientScript;manager.RegisterClientScriptResource(typeof(Class1), "JSControl.JScript1.js");}base.OnPreRender(e);}}}
6. Add the reference of JSControl. dll to the js project.
7. Register JSControl. dll on the page where you want to call the script
<%@ Register Assembly="JSControl" Namespace="JSControl" TagPrefix="zhi" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
8. Call
<script type="text/javascript">$(function (){showAlert();});</script>
Compile a c ++ method into a dll file
Put the method in a DLL project and add _ declspec (dllexport) to export the function.
In B/S mode, how does one Call dll files through js?
There are many links in the following content, which are similar to this one !!!