0

我想添加一个客户端 JavaScript 事件处理程序,每次在 ASP.NET Telerik RadGrid 上选择或取消选择一行时都会触发该事件处理程序,我需要从 JavaScript 添加它而无需服务器端代码。我怎样才能做到这一点?

4

1 回答 1

0

您可以通过使用RadAjaxManager来实现这一点。ASPX:

 <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" 
            onajaxrequest="RadAjaxManager1_AjaxRequest"></telerik:RadAjaxManager>

JS:

<script type="text/javascript">
    function onclientrowclick(sender, args) {

        $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest();
    }
 </script>

C#:

 protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
    {
            //your code
    }

编辑:

 <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="true" AllowMultiRowSelection="true"  >
      <ClientSettings Selecting-AllowRowSelect="true">
      <ClientEvents OnRowSelecting="OnRowSelecting" OnRowDeselecting="OnRowDeselecting" />
      </ClientSettings>
        </telerik:RadGrid>

JS:

 function OnRowDeselecting(sender, args) {
        alert("deselect");
    }
    function OnRowSelecting(sender, args) {
        alert("select");
    }
于 2013-10-23T09:55:52.840 回答