js调用前台嵌入的c#方法:
页面嵌入的c#方法如下:
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Runtime.InteropServices" %>
<script language="c#" runat="server">
public string TestJSToFunction(string strTest)
{
return strTest;
}
public string TestJSToFunction()
{
return "JS调用页面c#方法";
}
public string TestJSToFunction(string strTest, string ss)
{
return strTest;
}
</script>
其中有不含参数的方法,含一个,含两个参数的方法。
js可以这样写:
// 2014-2-20添加测试 获取SL中页面代码中变量值
function getUserNamePwd(userName, Pwd) {
//alert(userName + "\n" + Pwd);
var name = userName + ',' + Pwd;
var pwd = Pwd;
var stt='<%=TestJSToFunction("' + name+','+pwd + '") %>';
alert(stt);
return "返回验证结果:";
}
上述语句中 var stt='<%=TestJSToFunction("' + name+','+pwd + '") %>';调用含有一个参数的c#方法。
目前还没有发现可以调用两个参数的js的写法。
有问题,Q我1419226548或者981243247