CS裡
復制代碼 代碼如下:public string test()
{
return "Hello World";
}
aspx 頁面
<html xmlns="
<head runat="server">
<title>無標題頁</title>
<mce:script type="text/javascript" ><!
var demo=function(){
var b= "<%=test() %>";
alert(b);
}
//
</head>
<body>
<form id="form
<div>
<input type="button" id="id
</div>
</form>
</body>
</html>
上面的是不帶參數的
CS:
public string test(string a)
{
return a;
}
aspx:
<html xmlns="
<head runat="server">
<title>無標題頁</title>
<mce:script type="text/javascript" ><!
var demo=function(){
var a="Hello World";
var b=
alert(b);
}
//
</head>
<body>
<form id="form
<div>
<input type="button" id="id
</div>
</form>
</body>
</html>
總結
調用不成功!萬惡的單引號和雙引號啊!!!
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20337.html