CS里
復制代碼 代碼如下:
public string test()
{
return "Hello World";
}
復制代碼 代碼如下:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>無標題頁</title>
<mce:script type="text/javascript" ><!--
var demo=function(){
var b= "<%=test() %>";
alert(b);
}
// --></mce:script>
</head>
<body>
<form runat="server">
<div>
<input type="button" value="JS調用CS" />
</div>
</form>
</body>
</html>
復制代碼 代碼如下:
public string test(string a)
{
return a;
}
復制代碼 代碼如下:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>無標題頁</title>
<mce:script type="text/javascript" ><!--
var demo=function(){
var a="Hello World";
var b= '<%=test("'+a+'") %>';//這里一定注意單引號和雙引號的使用!!!!!
alert(b);
}
// --></mce:script>
</head>
<body>
<form runat="server">
<div>
<input type="button" value="JS調用CS" />
</div>
</form>
</body>
</html>
新聞熱點
疑難解答
圖片精選