asp:Button not firing on first click when in PopupControlExtender

  • Thread starter Thread starter mazdotnet
  • Start date Start date
M

mazdotnet

Hi all,

I'm really stuck trying to figure the following out. I have been
working on a shopping portal where you can select products from a list
inside a repeater on the bottom of the page and on each row, once
clicked you can enter a quantity and add it to your cart automatically
on top (using UpdatePanel). Everything seems to be working fine when I
created a dummy DataTable and did a bind but now that I'm actually
reading the contents of my DataTable from a database it just does fire
the first time you click the Add button (second time is fine) which is
really odd (seems like bug). As soon as I change it to read from my
own generated DataTable (same columns) it works fine. On each row
there is Plus sign once clicked opens up a popup (using
PopupControlExtender) containing a Qty textbox and an Add button. I
even set a breakpoint on my rptAvailableProducts_ItemCommand which is
doesn't catch the event the first time you click Add. However, second
time clicked works fine.

I've included a sample code below. Anyone knows why it's not firing
the first time? why the event is lost?

<asp:Panel ID="Panel1" runat="server" CssClass="popupControl">
<asp:UpdatePanel runat="server" ID="up1">
<ContentTemplate>
<div class="subArea1">
<!-- hidden value -->
<span class="sku">SKU:</span> <asp:Label ID="lblSKU" runat="server"
Text='<%# Eval("SKU") %>'></asp:Label><br />
<asp:Label ID="lblProductName" runat="server" Text='<%#
Eval("ProductName") %>'></asp:Label>

<div style="text-align:right;">

QTY: <asp:TextBox ID="tbxQty" CssClass="qtyTextBox1" runat="server"
AutoPostBack="true"></asp:TextBox> <asp:RangeValidator ID="rvtbxQty"
runat="server" ControlToValidate="tbxQty" Display="Dynamic"
ErrorMessage="* Quantity incorrect" MinimumValue="1"
MaximumValue="1000000" Type="Integer"></asp:RangeValidator>

<asp:Button ID="btnAdd1" runat="server" CssClass="btnPopupAdd"
Text="Add" CommandArgument="1" CommandName="Click"
UseSubmitBehavior="False" /><br />
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>

</asp:Panel>

<cc1:PopupControlExtender ID="PopupControlExtender1" runat="server"
TargetControlID="iAdd1"
PopupControlID="Panel1" Position="Bottom" OffsetY="10" />

.cs

protected void rptAvailableProducts_ItemCommand(object source,
RepeaterCommandEventArgs e)
{
if (e.CommandName == "Click")
{ ...
....
....


Thanks all
 
In UpdatePanel add Triggers section with AsyncPostBack and assign the said
buttons controlID there

Then you are done.
 
Back
Top