0

在这里你可以看到我的 html 代码。我需要运行 OnSelectedIndexChanged 事件,但我必须防止回发所有页面。我应该怎么办?

<asp:UpdatePanel runat="server" ID="upRemittance">
            <ContentTemplate>

                    <asp:RadioButtonList runat="server" ID="rblRemittance" AutoPostBack="True" OnSelectedIndexChanged="rblRemittance_OnSelectedIndexChanged">
                    </asp:RadioButtonList>

            </ContentTemplate>
        </asp:UpdatePanel>

RadioButtonList 绑定方法:

  List<remittance> remittances = _mainService.RemitanceActiveList().ToList();
            if (remittances.Count > 0)
            {
                rblRemittance.DataSource = remittances;
                rblRemittance.DataTextField = "BankName";
                rblRemittance.DataValueField = "RemitanceId";
                rblRemittance.DataBind();
            }
4

1 回答 1

0

我用ajax调用解决它。

 <script type="text/javascript">
    $(document).ready(function () {
        $("input[type = radio]").each(function (index, value) {
            $(value).click(function () {

                $.ajax({
                    type: "POST",
                    url: "http://localhost:2782/TestPage.aspx/GetBank",
                    data: "{id:" + value.defaultValue + "}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (data) {
                        $("#dvBankInfo").empty();
                        $("#dvBankInfo").append(data.d);
                    }
                });
            });
        });
    });
</script>
于 2013-05-30T14:56:37.430 回答