ASP.NET Update Panel with CheckBox - Not Working Properly

Posted by rwponu on Stack Overflow See other posts from Stack Overflow or by rwponu
Published on 2010-04-15T15:57:39Z Indexed on 2010/04/15 16:13 UTC
Read the original article Hit count: 656

Filed under:
|
|

I'm working on a simple demo project so that I can learn some things about ASP.NET's AJAX capabilities. My problem is that I can't seem to get an UpdatePanel to work properly with a CheckBox inside of it. Here is the markup I'm using in my .aspx file:

<asp:ScriptManager ID="SM1" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <tr>
            <td><asp:CheckBox ID="chkPaypal" runat="server" Text="Paypal" OnCheckedChanged="PayPal_CheckedChanged" AutoPostBack="true" /></td>
        </tr>
        <asp:Panel ID="pnlPayPal" runat="server" Visible="false">
            <tr>
                <td>&nbsp;&nbsp;<asp:Label runat="server" ID="lblPaypalEmail" Text="Email:" /></td>
                <td><asp:TextBox runat="server" ID="tbPaypalEmail" Text="" Width="250px" /></td>
            </tr>
            <tr><td>&nbsp;</td></tr>
        </asp:Panel>
    </ContentTemplate>
    <Triggers>
        <asp:ASyncPostBackTrigger ControlID="chkPayPal" />
    </Triggers>
</asp:UpdatePanel>

In my code behind, I'm simply saying:

protected void PayPal_CheckedChanged(object sender, EventArgs e)
{
    pnlPayPal.Visible = true;
}

Instead of making the panel visible as I anticipate, it is adding another "PayPal" checkbox at the top of the page. Any ideas?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about c#