javaScript函数中执行C#代码中的函数:方法一:1、首先建立一个按钮,在后台将调用或处理的内容写入button_click中;2、在前台写一个js函数,内容为document.getElementById("btn1").click();3、在前台或后台调用js函数,激发click事件,等于访问后台c#函数;方法二:1、函数声明为public 后台代码(把public改成protected也可以)public string ss(){return("a");}2、在html里用<%=fucntion()%>可以调用前台脚本<script language=javascript>var a = "<%=ss()%>";alert(a);</script>方法三:1、<script language="javascript"><!--function __doPostBack(eventTarget, eventArgument){var theForm = document.Form1; //指runat=server的formtheForm.__EVENTTARGET.value = eventTarget;theFrom.__EVENTARGUMENT.value = eventArgument;theForm.submit();}--></script><input id="Button1" type="button" name="Button1" value="按钮" οnclick="javascript:__doPostBack('Button1','')">方法四:<script language="javascript">function SubmitKeyClick(){if (event.keyCode == 13){event.cancelBubble = true;event.returnValue = false;document.all.FunName.value="你要调用的函数名";document.form[0].submit();}}</script><INPUT οnkeypress="SubmitKeyClick()" id="aaa" type="text"><input type="hidden" name="FunName"> 〈!--用来存储你要调用的函数 --〉在.CS里有:public Page_OnLoad(){if (!Page.IsPost()){string strFunName=Request.Form["FunName"]!=null?Request.Form["FunName"]:"";//根据传回来的值决定调用哪个函数switch(strFunName){case "enter()":enter() ; //调用该函数break;case "其他"://调用其他函数break;default://调用默认函数break;}}}public void enter(){//……比如计算某值}