Using visual-studio: Using onCheckedChanged with PopupControlExtender and want to prevent popup when unchecking on newest questions tagged visual-studio – Stack Overflow

I am still reasonably new to this and have tried to find an answer, so hopefully I am not repeating this.

I am using ASP.NET and have a checkbox control that brings up a popup box when it’s changed, using the onCheckedChanged method. This popup box has some info in it and a ‘Close’ button which successfully closes the popup.

What I want is to prevent the popup appearing if the checkbox is being unchecked. I currently have the onCheckedChanged calling a code behind method which cancels the extender call if the control is not checked, but the popup quickly appears before it is closed. How can I prevent it this?

This is the appropriate page code:

        <div class="row" id="divDDMandate" runat="server">

        <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Always">
            <ContentTemplate>
                <asp:CheckBox ID="chkDDMandate" Width="20px" Visible="true" runat="server" AutoPostBack="true"
                 OnCheckedChanged="clientchkDDMandateChanged(this);" on  />
                <asp:Literal ID="ltlDDMandate" runat="server">Direct Debit Mandate (by post)</asp:Literal>

            <asp:PopupControlExtender ID="chkDDMandate_PopupControlExtender" runat="server"
                DynamicServicePath="" Enabled="true" PopupControlID="PanelDDMandateDownload"
                TargetControlID="chkDDMandate"
                Position="Bottom" OffsetX="-20" OffsetY="10" />
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>

…and this is my code behind method:

        protected void chkDDMandateChanged(object sender, EventArgs e)
    {
        //Cancel the panel if unchecking
        if ((!chkDDMandate.Checked) && chkDDMandate_PopupControlExtender.Enabled)
        {
            chkDDMandate_PopupControlExtender.Cancel();
        }
    }

I would be grateful for any help.

Cheers

See Answers


source: http://stackoverflow.com/questions/11409147/using-oncheckedchanged-with-popupcontrolextender-and-want-to-prevent-popup-when
Using visual-studio: using-visual-studio



online applications demo