ASP.NET Update Panel with CheckBox - Not Working Properly
- by rwponu
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> <asp:Label runat="server" ID="lblPaypalEmail" Text="Email:" /></td>
<td><asp:TextBox runat="server" ID="tbPaypalEmail" Text="" Width="250px" /></td>
</tr>
<tr><td> </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?