I'm having an issue with a button inside an update panel (inside a Modal Popup) that populates a listbox in another update panel. Whenever you click the button to populate the listbox, nothing happens the first time. Each subsequent click will populate the listbox with the last input.
The Button in question is either "btnAddExistingContact"(resides in "upnlCallReport" update panel) or "btnAddExistingContactSubmit" (resides in "upnlAddExistingContact")
Here's the panel thats displayed in the Modal Popup:
<asp:UpdatePanel
ID="upnlAddExistingContact" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="pnlAddExistingContact" runat="server" BackColor="WhiteSmoke" style="display:normal" BorderColor="Black" BorderStyle="Solid">
Add Existing Contacts
<br />
<asp:Panel ID="pnlContactGridView" runat="server" ScrollBars="Auto" HorizontalAlign="Center" Height="400" Width="1000">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:GridView
ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3"
DataKeyNames="ID" DataSourceID="SqlDataSource3" GridLines="Vertical" Height="400px" Width="1000px" OnSorting="GridView1_Sorting">
<AlternatingRowStyle BackColor="#DCDCDC" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ID" InsertVisible="False" SortExpression="ID">
<EditItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("ID") %>'></asp:Label>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblIDGrid" runat="server" Text='<%# Bind("ID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Name" SortExpression="Name">
<EditItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Name") %>'></asp:Label>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblNameGrid" runat="server" Text='<%# Bind("Name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
<asp:BoundField DataField="JobFunction" HeaderText="Job Function" SortExpression="JobFunction" />
<asp:BoundField DataField="Phone_Work" HeaderText="Phone (Work)" SortExpression="Phone_Work" />
<asp:BoundField DataField="Phone_Home" HeaderText="Phone (Home)" SortExpression="Phone_Home" />
<asp:BoundField DataField="Phone_Mobile" HeaderText="Phone (Mobile)" SortExpression="Phone_Mobile" />
<asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
</Columns>
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#0000A9" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#000065" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:SQL2012_279191_cwgcrmConnectionString %>" SelectCommand="SELECT [ID], [FName] + ' ' + [LName] as [Name], [Title], [JobFunction], [Phone_Work], [Phone_Home], [Phone_Mobile],
[Email] FROM [tblCustomer_Contact] WHERE ([fkCustomer] = @fkCustomer) ORDER BY [Name]">
<SelectParameters>
<asp:ControlParameter ControlID="ddlCustomer" DefaultValue="0" Name="fkCustomer" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="GridView1" EventName="Sorting" />
<asp:AsyncPostBackTrigger ControlID="GridView1" EventName="Sorted" />
</Triggers>
</asp:UpdatePanel>
</asp:Panel>
<asp:Button ID="btnAddExistingContactSubmit" runat="server" Text="Add Contact" OnClick="btnAddExistingContactSubmit_Click" />
<asp:Button ID="btnAddExistingContactCancel" runat="server" Text="Cancel" OnClick="btnAddExistingContactCancel_Click" />
<asp:Button ID="btnEditContact" runat="server" OnClick="btnEditContact_Click" Text="Edit Contact" />
<asp:ModalPopupExtender
ID="mpeEditExistingContact" runat="server" Enabled="True"
TargetControlID="btnEditContact" PopupControlID="pnlEditExistingContact" CancelControlID="btnEditExistingContactCancel" OkControlID="btnEditExistingContactSubmit">
</asp:ModalPopupExtender>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</div>
Here's the updatepanel (it's the main page) that includes the Listbox:
<asp:UpdatePanel
ID="upnlCallReport" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table class="auto-style1">
<tr>
<td class="auto-style5">Salesperson</td>
<td class="auto-style6">
<asp:DropDownList ID="ddlSalesperson" runat="server" Width="300px" DataSourceID="SqlDataSource1" DataTextField="Name" DataValueField="ID" AutoPostBack="True">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:SQL2012_279191_cwgcrmConnectionString %>"
SelectCommand="SELECT [ID], [LName] + ', ' + [FName] as Name FROM tblSalesperson ORDER BY [Name]"></asp:SqlDataSource>
</td>
<td> </td>
</tr>
<tr>
<td class="auto-style5">Customer</td>
<td class="auto-style6">
<asp:DropDownList ID="ddlCustomer" runat="server" Width="300px" DataSourceID="SqlDataSource2" DataTextField="Name" DataValueField="ID" AutoPostBack="True">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:SQL2012_279191_cwgcrmConnectionString %>"
SelectCommand="SELECT c_p.Name + ', ' + c_p.City + ', ' + c_p.State as Name, c_p.ID
FROM tblCustomer_Profile c_p
INNER JOIN tblCustomer_Salesperson c_sp
ON c_p.ID = c_sp.fkCustomerID
INNER JOIN tblSalesperson sp
ON c_sp.fkSalespersonID = sp.ID
WHERE getDate() BETWEEN c_sp.StartDate AND c_sp.EndDate AND sp.ID = @ID ORDER BY Name">
<SelectParameters>
<asp:ControlParameter ControlID="ddlSalesperson" Name="ID" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
</td>
<td> </td>
</tr>
<tr>
<td class="auto-style5">Date</td>
<td class="auto-style6">
<asp:TextBox ID="txtDate" runat="server">
</asp:TextBox>
<asp:TextBoxWatermarkExtender ID="txtDateTextBoxWatermarkExtender" runat="server" Enabled="True" TargetControlID="txtDate" WatermarkText="mm/dd/yyyy" WatermarkCssClass="watermark">
</asp:TextBoxWatermarkExtender>
<asp:PopupControlExtender ID="txtDate_PopupControlExtender" runat="server" DynamicServicePath="" Enabled="True" ExtenderControlID="" PopupControlID="pnlCalendar" Position="Right" TargetControlID="txtDate">
</asp:PopupControlExtender>
</td>
<td> </td>
</tr>
<tr>
<td class="auto-style5">Contacts</td>
<td class="auto-style6">
<asp:ListBox ID="lbContacts" runat="server" Height="100px" Width="300px" BorderColor="#CCCCCC" BorderStyle="Ridge"></asp:ListBox>
</td>
<td>
<asp:Button ID="btnAddExistingContact" runat="server" Text="Add Existing Contact" OnClick="btnAddExistingContact_Click" />
<br />
<asp:Button ID="btnAddNewContact" runat="server" Text="Add New Contact" OnClick="btnAddNewContact_Click" />
</td>
</tr>
<tr>
<td class="auto-style5">Summary</td>
<td class="auto-style6">
<asp:TextBox ID="txtSummary" runat="server" Height="100px" Width="300px" BorderColor="#CCCCCC" BorderStyle="Ridge" TextMode="MultiLine"></asp:TextBox>
</td>
<td> </td>
</tr>
<tr>
<td class="auto-style5">Details</td>
<td class="auto-style6">
<asp:Panel ID="pnlDetails" runat="server" Height="200px" HorizontalAlign="Center" ScrollBars="Vertical" Width="300px" BorderColor="#CCCCCC" BorderStyle="Ridge">
</asp:Panel>
</td>
<td>
<asp:Button ID="btnAddNewDetail" runat="server" Text="Add New Detail" OnClick="btnAddNewDetail_Click" />
</td>
</tr>
</table>
<asp:Panel ID="pnlCallReport" runat="server">
<asp:Button ID="btnModalAddExistingContact" runat="server" Text="Modal Popup Control" style="display:none" />
<asp:Button ID="btnModalAddNewContact" runat="server" Text="Modal Popup Control" style="display:none" />
<asp:Button ID="btnModalEditExistingContact" runat="server" Text="Modal Popup Control" style="display:none" />
<asp:Button ID="btnModalAddNewDetail" runat="server" Text="Modal Popup Control" style="display:none" />
<asp:ModalPopupExtender
ID="mpeAddExistingContact" runat="server" Enabled="True"
TargetControlID="btnModalAddExistingContact" PopupControlID="pnlAddExistingContact" CancelControlID="btnModalAddExistingContact">
</asp:ModalPopupExtender>
<asp:ModalPopupExtender
ID="mpeAddNewContact" runat="server" Enabled="True"
TargetControlID="btnModalAddNewContact" PopupControlID="pnlAddNewContact" CancelControlID="btnModalAddNewContact">
</asp:ModalPopupExtender>
<asp:ModalPopupExtender
ID="mpeAddNewDetail" runat="server" Enabled="True"
TargetControlID="btnModalAddNewDetail" PopupControlID="pnlAddNewDetail" CancelControlID="btnModalAddNewDetail">
</asp:ModalPopupExtender>
<asp:Button ID="btnCallReportSubmit" runat="server" Text="Button" />
<asp:Button ID="btnCallReportCancel" runat="server" Text="Button" />
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>