一、后台(.cs文件)方法:
public string GetString(string name)
{
return ("Hello " + name);
}
public string GetString()
{
return ("Hello");
}
二、前台文件内容:
<html>
<head>
<title></title>
</head>
<script language="javascript" type="text/javascript">
function GetString() {
var reval = '<%=GetString()%>';
alert(reval);
}
function GetStringByPara() {
var str = "EveryOne";
var reval = '<%=GetString("' + str + '")%>';
alert(reval);
}
</script>
<body>
<a href="javascript:GetString();">无参调用</a><br />
<a href="javascript:GetStringByPara();">调用</a>
</body>
</html>
Javascript函数中调用C#方法
最新推荐文章于 2022-05-05 22:40:20 发布