JS调用CS里的带参方法 .
js调用CS里的方法有很多,我用一种简单的方法,如下
CS里
[c-sharp]
view plaincopyprint?
- public string test()
- {
- return "Hello World";
- }
aspx 页面
[c-sharp]
view plaincopyprint?
- <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);
- }
-
-
- </head>
- <body>
- <form id="form1" runat="server">
- <div>
- <input type="button" id="id1" onclick="demo()" value="JS调用CS" />
- </div>
- </form>
- </body>
- </html>