在这里你可以看到我的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();
}
答案 0 :(得分: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>