单击Rad Grid中的复选框调用ASP.Net HTTP处理程序

时间:2013-09-05 12:39:14

标签: javascript jquery asp.net c#-4.0 radgrid

我在asp.net网站上有一个rad网格。我只是一个使用rad Grid的初学者。我有这样的绑定网格。

  <telerik:RadGrid ID="RadGrid1" runat="server">
        <MasterTableView>
            <Columns>
                <telerik:GridTemplateColumn DataField="Text">
                    <HeaderTemplate>
                        <asp:CheckBox ID="HeaderCheckBox1" runat="server" ClientIDMode="Static" />
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:CheckBox ID="CheckBox1" runat="server" />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
        </MasterTableView>
        <ClientSettings>
            <ClientEvents OnCommand="gridCommand" OnRowDataBound="gridRowBound" />
        </ClientSettings>
    </telerik:RadGrid>

现在在脚本中我写了类似的东西,但它没有用。

  $(document).ready(function () {
            $('#<%= HeaderCheckBox1.ClientID %>').click(function () {
                alert("Checked");
            });

我尝试过一种简单的方法,比如

$("#HeaderCheckBox1").click(function(){
});

那也不起作用。我的问题是我想点击这个复选框调用HTTP Handler,该复选框出现在rad Grid的标题中。请尽快帮忙。还请告诉我调用HTTP句柄的方法。 Althogh在互联网上有很多例子,但我仍然感到困惑,我们可以用post调用Http处理程序,或者只用get调用。

我已经知道http处理程序在调用其url时会返回数据。那么,通过使用脚本调用处理程序,它也会改变URL吗?

Rad Grid只支持Asp.net服务器控件,如果我想添加 简单的html输入类型然后它也给出了错误。 像

<input type="checkbox" id="blabla"/>.

请帮帮我

1 个答案:

答案 0 :(得分:1)

   $(document).ready(function () {
        $("#<%=RadGrid1.ClientID%> input[id*="HeaderCheckBox1"]:checkbox").click(function () {
           // write code http handler 
            alert("Checked");
        });

然后编写用于调用http处理程序的代码以获取更多信息,请通过以下链接 http://brijbhushan.net/2011/05/29/call-httphandler-from-jquery-pass-data-and-retrieve-in-json-format/