是吗? 测试通过呀。
JS写在<head>里
C#写在类中,public型
public string bindInfo(string a)
{
return a + "来了";
}using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;namespace WebApplicationDemo
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ } public string bindInfo(string a)
{
return a + "来了";
}
}
}
JS写在<head>里
C#写在类中,public型
public string bindInfo(string a)
{
return a + "来了";
}using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;namespace WebApplicationDemo
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ } public string bindInfo(string a)
{
return a + "来了";
}
}
}
<head runat="server">
<title></title>
<script type="text/javascript">
function SubmitKeyClick() {
var a = "fdsa";
alert(' <%= bindInfo("' + a + '") %>');
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="button" value="调用后台" onclick="return SubmitKeyClick()" />
</div>
</form>
</body>
</html>
调用方法:用<% String bbb= bindInfo("a"); %>然后:<%=bbb%>