RoryWong Brain Beats Brawn

.NET 从后台传值、函数到前台JS

 

notice:    js加载写在body或者之后,在head中会报错

前台js:(传变量值)

<script type="text/javascript" charset="utf-8">

  var loginStation = <%= canUseSta%>;
  var StaitonDatas = <%= datas%>;

</script>

----------------------------------

后台cs:

//根据具体情况为变量赋值

  public string datas;
  public string canUseSta;

----------------------------------

后台往前台传方法:

  var something = <%=getSometing()%>;    

C#代码:

   public static string getSometing()    {  return  "返回值";   }    

posted @ 2016-12-28 11:16  FerryYang  阅读(3035)  评论(0编辑  收藏  举报