本文介绍了在ASP.NET中调用C#到Javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 限时删除!! 请帮助我, 如何在asp.net中调用c#中的public void(BlueOn)到javasript(StartBlink)? C# 名称空间 ArduinoTest { public partial class LEDTest:System .Web.UI.Page { SerialPort ardo; 受保护 void Page_Load(对象 sender,EventArgs e) { ardo = new SerialPort(); ardo.PortName =& quot; COM4& quot ;; ardo.BaudRate = 9600 ; // BlueOn(); } [WebMethod] public void BlueOn() { string blue =& quot; 1& quot ;; ardo.Open(); ardo.Write(蓝色); ardo.Close(); } Asp.Net中的JS < asp:ScriptManager ID = ScriptManager2 runat = server EnablePageMethods = true > < / asp:ScriptManager > < script 类型 = text / javascript > 函数StartBlink(){ } 解决方案 Please help me,how to call a public void (BlueOn) in c # to javasript (StartBlink) in asp.net?C#namespace ArduinoTest{ public partial class LEDTest : System.Web.UI.Page { SerialPort ardo; protected void Page_Load(object sender, EventArgs e) { ardo = new SerialPort(); ardo.PortName = "COM4"; ardo.BaudRate = 9600; //BlueOn(); } [WebMethod] public void BlueOn() { string blue = "1"; ardo.Open(); ardo.Write(blue); ardo.Close(); }JS in Asp.Net<asp:ScriptManager ID="ScriptManager2" runat="server" EnablePageMethods="true"></asp:ScriptManager> <script type="text/javascript"> function StartBlink() { } 解决方案 这篇关于在ASP.NET中调用C#到Javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的.. 09-07 20:01