<span style="cursor:hand;" onclick="UpDateScore(<%#Eval("ID")%>)"  >投票</span>public  void UpDateScore(string id)
{
xxxxxxx
}如何才能够实现这个投票功能呢?
怎么才能调用到自定义的函数

解决方案 »

  1.   

    楼主这个是不行的,onclick事件的处理方法,必须是类似UpDateScore(object sender, EventArgs e)这样的,否则这个事件没办法注册成功的,看看委托和事件就知道了。
      

  2.   

    onclick调用的是客户端JS方法而不是后台代码类中的方法,楼主研究一下__doPostBack方法可以帮你实现,大致方式为:<span style="cursor:hand;" onclick="UpDateScore('<%#Eval("ID")%>')"  >投票 </span> <script type="text/javascript">function UpDateScore(id){    __doPostBack('controlname',id);}</script>
      

  3.   

    使用ajax.dll可以实现你的需求
      

  4.   

    如果要用
    linkbutton
    来做,又应该如何操作呢?
    听说用linkbutton比较方便
      

  5.   


    span不像button,本身不需要OnServerClick,如果坚持要用span,就要用回调了(人称ajax)。
      

  6.   

    linkbutton 跟button一样的使用
    可是 我的是绑定在repeater控件里的我需要实现 点击 投票 然后调用 public  void UpDateScore() 

    xxxxxxx 
    } 就把该条记录的投票数增一
    网上找的linkbutton 用法不合适我呢