博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

asp.net前台调用后台方法传参数

Posted on 2009-10-30 22:54  eevann  阅读(1842)  评论(0)    收藏  举报

方法一:前台调用后台方法传参数

 

   1: <script>
   2: function Show()
   3: {
   4: var Keys=0;
   5: var a="<%=ButtShow(""+strid+"") %>";  //调用后台变量
   6:  
   7: }
   8: </script>
   9:  
  10: public string strid = "000";
  11:   public string ButtShow(string strs)
  12:     {    
  13:  
  14:  
  15:             return strs;
  16:                
  17:     }
  18:  

方法二:不传参数

 

   1: <script>
   2: function Show()
   3: {
   4: var Keys=0;
   5: var a="<%=ButtShow() %>";  //调用后台变量
   6:  
   7: }
   8: </script>
   9:  
  10: public string strid = "000";
  11:   public string ButtShow(string strs)
  12:     {    
  13:  
  14:  
  15:             return "123";
  16:                
  17:     }
  18:  

方法三:直接传参数

   1: <script>
   2: function Show()
   3: {
   4: var Keys=0;
   5: var a="<%=ButtShow("0") %>";
   6:  
   7: }
   8: </script>
   9:  
  10: public string strid = "000";
  11:   public string ButtShow(string strs)
  12:     {    
  13:  
  14:  
  15:             return "123";
  16:                
  17:     }
  18: