0
我創建了一個多選CheckBoxList的面板,通過PopControl擴展器連接到TextBox。Popextender在提交後關閉面板
我正在使用PopControl
擴展器的.commit()
方法來顯示所選項目。
當我從CheckBox中選擇一個項目時,面板關閉,我想選擇該項目而不關閉面板。
我在做什麼錯?當您單擊其中一個複選框導致它有AutoPostBack = "true"
標記
<asp:TextBox ID="txtCountry" runat="server" Skinid="longTextbox" AutoPostBack = "false" OnClientItemSelected="passtohidden()" />
<asp:Panel ID="pnlLocation" runat="server">
<asp:UpdatePanel runat="server" ID="upLocation">
<ContentTemplate>
<asp:CheckBoxList ID="chkLocation" SkinID ="chkColor" runat="server" AutoPostBack = "true" onselectedindexchanged="chkLocation_SelectedIndexChanged" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="txtCountry" EventName="TextChanged" />
</Triggers>
</asp:UpdatePanel>
</asp:Panel>
<asp:PopupControlExtender ID="Panel1_PopupControlExtender" runat="server" Enabled="True" Position="Bottom" PopupControlID = "pnlLocation" TargetControlID="txtCountry" />
代碼背後
protected void chkLocation_SelectedIndexChanged(object sender, EventArgs e)
{
string strSelected = "";
foreach (ListItem l in chkLocation.Items)
{
if (l.Selected)
{
strSelected += l.Text + " ,";
}
}
//txtCountry.Text = strSelected;
Panel1_PopupControlExtender.Commit(strSelected);
}