是吗? 测试通过呀。
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 + "来了";
        }
    }
}

解决方案 »

  1.   

    HTML段贴错了,如下正确:<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplicationDemo._Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
    <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>
      

  2.   

    <%= bindInfo("' + a + '") %>C#?    应该不这么写, JAVA 里面是不可以的,  我想他们都是一样的。
    调用方法:用<% String bbb= bindInfo("a"); %>然后:<%=bbb%>