当我点击asp.net页面上的按钮控件时,我的radiobuttonlist在回发后返回未经检查。
<asp:RadioButtonList ID="rblSgkOzel" runat="server" EnableViewState="true">
<asp:ListItem Text="SGK Kapsamında" Value="sgk" Selected="True"/>
<asp:ListItem Text="Özel" Value="ozel" />
<asp:ListItem Text="Hasta Adına" Value="hasta" />
</asp:RadioButtonList>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="denemeRepeater.aspx.cs"
Inherits="KlinikMuhasebe.denemeRepeater" %>
<%@ Import Namespace="MedulaRADClassLib" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="JS/reset-fonts-grids.css" rel="stylesheet" type="text/css" />
<link href="css.css" rel="stylesheet" type="text/css" />
<link href="_cssV3.css" rel="stylesheet" type="text/css" />
<script src="JS/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="JS/liquid-canvas.js" type="text/javascript"></script>
<script src="JS/liquid-canvas-plugins.js" type="text/javascript"></script>
<script type="text/javascript" src="js_Eski/JScript.js" language="javascript"></script>
<script type="text/javascript" src="js_Eski/overlib.js" language="javascript"></script>
<script src="JS/boxy/jquery.boxy.js" type="text/javascript"></script>
<style>
.imgOpenClose
{
}
body
{
color: Black;
}
</style>
<script type="text/javascript">
$(document).ready(function() {
$('.imgOpenCloseKurum').click(function() {
if ($(this).attr("src") == "images/openTree.gif") {
$(this).attr("src", "images/closeTree.gif");
$($(this).parent().get(0)).find('div').eq(0).show();
}
else {
$(this).attr("src", "images/openTree.gif");
$($(this).parent().get(0)).find('div').eq(0).hide();
}
});
$('.imgOpenClose').click(function() {
if ($(this).attr("src") == "images/openTree.gif") {
$(this).attr("src", "images/closeTree.gif");
$(this).parent().find('div').eq(0).show();
}
else {
$(this).attr("src", "images/openTree.gif");
$(this).parent().find('div').eq(0).hide();
}
});
$("input:radio").click(function() {
$("input:radio").each(function() {
$(this).attr("checked", "")
});
$(this).attr("checked", "checked");
}).attr("checked", "");
$("input:checkbox").click(function() {
if ($(this).attr('checked')) {
$(this).next().html("Ücretli Seans");
//$(this).attr('checked', '');
}
else {
$(this).next().html("Bedelsiz Seans");
//$(this).attr('checked', 'checked');
}
})
});
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div style="text-align: left;">
<div class="divKriter">
<table>
<thead>
<tr>
<th colspan="2">
FATURA BASKI KRİTERLERİ
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<asp:RadioButtonList ID="rblSgkOzel" runat="server" EnableViewState="true">
<asp:ListItem Text="SGK Kapsamında" Value="sgk" Selected="True"/>
<asp:ListItem Text="Özel" Value="ozel" />
<asp:ListItem Text="Hasta Adına" Value="hasta" />
</asp:RadioButtonList>
</td>
<td>
<asp:TextBox ID="txtTarihi" runat="server" ToolTip="Son Tarihi" />
<cc1:CalendarExtender ID="txtTarihi_CalendarExtender" runat="server" Enabled="True"
TargetControlID="txtTarihi" Format="dd.MM.yyyy">
</cc1:CalendarExtender>
<br />
<asp:CheckBox ID="cbBedelsiz" runat="server" Text="Ücretli Seans" Checked="true" />
<br />
<asp:Button ID="btnFaturaNolariGetir" runat="server" Text="Faturaları Getir" OnClick="btnFaturaNolariGetir_Click" />
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:DropDownList ID="ddlFaturaNolar" runat="server" />
<asp:Button ID="btnFaturaDetaylariniGetir" runat="server" Text="Fatura Detayları"
OnClick="btnFaturaDetaylariniGetir_OnClick" />
</td>
</tr>
</tbody>
</table>
</div>
<br />
<br />
<br />
<br />
<asp:Repeater ID="rptSGK" runat="server" OnItemDataBound="rpt_OnItemDataBound">
<ItemTemplate>
<div class="divKurumItem">
<img class="imgOpenCloseKurum" src="images/openTree.gif" />
<asp:RadioButton ID="rbKurum" runat="server" GroupName="rbKurumlar" />
<%# DataBinder.Eval(Container.DataItem, "kurumAdi")%>
<div style="display: none; margin-left: 10px;">
<asp:Repeater ID="rptHastalar" runat="server" OnItemDataBound="rptHastalar_OnItemDataBound">
<ItemTemplate>
<div style="display: block; margin-left: 10px;">
<img class="imgOpenClose" src="images/openTree.gif" />
<%# DataBinder.Eval(Container.DataItem, "adiSoyadi")%><br />
<div id='hid_<%# DataBinder.Eval(Container.DataItem, "refHasta_id")%>' style="margin: 10px;
display: none;">
<asp:HiddenField runat="server" ID="hdn1" Value='<%# total = 0 %>' />
<asp:Repeater ID="rptSeanslar" runat="server">
<HeaderTemplate>
<table border="1" cellpadding="5" cellspacing="2" style="margin-left: 30px;">
<thead>
<tr>
<th>
Seans Tarihi
</th>
<th>
Başvuru No.
</th>
<th>
Fatura Teslim No.
</th>
<th>
Fatura No.
</th>
</tr>
</thead>
<tbody>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<%# DataBinder.Eval(Container.DataItem, "tarihi", "{0:d}") %>
</td>
<td>
<%# (rblSgkOzel.SelectedIndex==0) ? DataBinder.Eval(Container.DataItem, "basvuruNo") : "" %>
</td>
<td>
<%# (rblSgkOzel.SelectedIndex==0) ? DataBinder.Eval(Container.DataItem, "faturaTeslimNo") : "" %>
</td>
<td>
<%# (rblSgkOzel.SelectedIndex==0) ? DataBinder.Eval(Container.DataItem, "faturaNo") : ""%>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</tbody> </table> </div>
</FooterTemplate>
</asp:Repeater>
</div>
<asp:HiddenField runat="server" ID="hdn" Value='<%# total = total + 1 %>' />
</ItemTemplate>
<FooterTemplate>
<div style="width: 500px; text-align: right; display: block;">
Toplam Satır Sayısı:
<%# total %>
</div>
</FooterTemplate>
</asp:Repeater>
</div>
<br />
</div>
</ItemTemplate>
</asp:Repeater>
<br />
<br />
<asp:Repeater ID="rptOzel" runat="server" OnItemDataBound="rpt_OnItemDataBound">
<ItemTemplate>
<div class="divKurumItem">
<img class="imgOpenCloseKurum" src="images/openTree.gif" />
<asp:RadioButton ID="rbKurumOzel" runat="server" GroupName="rbKurumlar" />
<%# DataBinder.Eval(Container.DataItem, "kurumAdi")%>
<div style="display: none; margin-left: 10px;">
<asp:Repeater ID="rptHastalar" runat="server" OnItemDataBound="rptHastalar_OnItemDataBound">
<ItemTemplate>
<div style="display: block; margin-left: 10px;">
<img class="imgOpenClose" src="images/openTree.gif" />
<%# DataBinder.Eval(Container.DataItem, "adiSoyadi")%><br />
<div id='hid_<%# DataBinder.Eval(Container.DataItem, "refHasta_id")%>' style="margin: 10px;
display: none;">
<asp:HiddenField runat="server" ID="hdn1" Value='<%# total = 0 %>' />
<asp:Repeater ID="rptSeanslarOzel" runat="server">
<HeaderTemplate>
<table border="1" cellpadding="5" cellspacing="2" style="margin-left: 30px;">
<thead>
<tr>
<th>
Seans Tarihi
</th>
</tr>
</thead>
<tbody>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:CheckBox ID="cbSeansOzel" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "tarihi", "{0:d}") %>' />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</tbody> </table> </div>
</FooterTemplate>
</asp:Repeater>
</div>
<asp:HiddenField runat="server" ID="hdn" Value='<%# total = total + 1 %>' />
</ItemTemplate>
<FooterTemplate>
<div style="width: 500px; text-align: right; display: block;">
Toplam Satır Sayısı:
<%# total %>
</div>
</FooterTemplate>
</asp:Repeater>
</div>
<br />
</div>
</ItemTemplate>
</asp:Repeater>
</div>
</form>
</body>
</html>
答案 0 :(得分:2)
更新:发布更新后的代码后,我可以看出问题出在您的jQuery代码中。它被设置为在页面加载后取消选中所有单选按钮。
你需要改变这个:
$("input:radio").click(function() {
$("input:radio").each(function() {
$(this).attr("checked", "") //uncheck all radio buttons in page
});
$(this).attr("checked", "checked"); //check only the selected radio
}).attr("checked", ""); //Unchecks all radio buttons when page loads
To This:
$("input:radio").click(function() {
$("input:radio").each(function() {
$(this).attr("checked", "")
});
$(this).attr("checked", "checked");
});
我添加了注释来解释你的jQuery代码正在做什么。
答案 1 :(得分:2)
您是否在Page_Load
方法中绑定了列表?
如果是这样,请确保仅在未回发页面时才绑定,例如:
protected void Page_Load(object sender, EventArgs)
{
if (!IsPostBack)
{
//Bind to the list in this block
}
}