2 개의 CheckBoxList 컨트롤 (chk1 및 chk2)이 있습니다. CheckBoxList의 선택을 지우려면 비동기 포스트 백을 사용해야합니다. 다음은 선택이 있고, 아이템 chk2이 확인 된 경우 명확하지 CHK1됩니다CheckBoxList AJAX 비동기 포스트 백 문제
<asp:ScriptManager ID="sm1" runat="server" ></asp:ScriptManager>
<asp:UpdatePanel ID="upd" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="chk1" />
<asp:AsyncPostBackTrigger ControlID="chk2" />
</Triggers>
<ContentTemplate>
<asp:Label ID="result" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
<div style="overflow: auto; height: 150px;">
<asp:CheckBoxList runat="server" ID="chk1" OnDataBound="assignClickBehaviours" AutoPostBack="true">
<asp:ListItem Value="1" Text="One"></asp:ListItem>
<asp:ListItem Value="2" Text="Two"></asp:ListItem>
<asp:ListItem Value="3" Text="Three"></asp:ListItem>
<asp:ListItem Value="100" Text="..."></asp:ListItem>
<asp:ListItem Value="150" Text="One hundred and Fifty"></asp:ListItem>
</asp:CheckBoxList>
</div>
<div style="overflow: auto;">
<asp:CheckBoxList runat="server" ID="chk2" AutoPostBack="true">
<asp:ListItem Value="1" Text="One"></asp:ListItem>
<asp:ListItem Value="2" Text="Two"></asp:ListItem>
<asp:ListItem Value="3" Text="Three"></asp:ListItem>
</asp:CheckBoxList>
</div>
코드 뒤에이 :
protected void Page_Load(object sender, EventArgs e)
{
processChecks();
}
private void processChecks()
{
if(chk2.SelectedIndex>-1)
chk1.ClearSelection();
}
모든 일이 업데이트 패널에 배치 된 경우, 그것은 작동합니다. ..하지만 체크 박스에 150 개의 항목이있을 수 있기 때문에 하단에있는 항목이 선택되면 오버플로 : 자동 스크롤은 맨 위로 다시 넘깁니다. 배치 상태를 유지하려면 스크롤 상태가 필요합니다 (따라서 비동기 포스트 백이 필요합니다). 어떤 아이디어 또는 대안? 당신이 코드를 시도 할 수 있습니다
죄송 확실하지 유의하시기 바랍니다 이 코드는 내가 게시 한 코드와 어떻게 다른가요? – billfredtom