js調用CS裡的方法有很多
CS裡
public string test()
{
return "Hello World";
}
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>
<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;
}
[c
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>
<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/20133.html