c# 前台js 调用后台代码

JS:  
  var s = "<% Response.Write(test1("abc")); %>";  //Write(); 后需加 ;
    alert(s);
   
    var s2 = "<%=test1("abc") %>";  //= 后不能加 ;
    alert(s2);
   
    var s3="<%test2("bcd"); %>";  //无返回值不能用 = 和response.write
    alert(s3);
c#:

    public string test1(string str)
    {
        return "test1"+str;
    }
    public void test2(string str)
    {
        Response.Write("test2"+str);
    }

posted on 2012-12-13 15:01  canny_strive  阅读(170)  评论(0)    收藏  举报

导航