Search code examples
asp.netupdatepanelmodalpopupextender

Update an UpdatePanel from a ModalPopUpExtender


I can't get to update an updatepanel when it is being called upon by a modalpopupextender. It's a small search popup window, it has two parts the patient's name part and the history part. The popupextender is triggered by an image button and in the OnClick codebehind:

protected void imgSearchPrincipal_Click(object sender, ImageClickEventArgs e)
        {
            tblMedHistory.Visible = false; 
            upMedHistory.Update();
            pnlMedSrchPrincipal_Ext.Show();
        }

Here is the script for the pop up window:

<div runat="server" id="divMedSearch" class="cls_gen_style">
        <asp:Panel runat="server" ID="pnlMedSearch" >
            <table runat="server" class="tables_gen tblPop"><tr><td>

                <table style="border-spacing:0px">
                    <tr><td style="height:10px"></td></tr>
                    <tr><td colspan="6" class="tp_dotline"></td></tr>
                    <tr>
                        <td colspan="4" class="rw_header">SEARCH</td>
                        <td colspan="2" style="background-color:navy; text-align:center"><asp:LinkButton runat="server" ID="lbClose" Style="color:white" Text="CLOSE" OnClick="lbClose_Click"></asp:LinkButton> </td>
                    </tr>
                    <tr><td colspan="6" class="bt_dotline"></td></tr>
                    <tr><td style="height:7px"></td></tr>

                    <tr>
                        <td style="width:3px"></td>
                        <td>PATIENT NAME</td>
                        <td><input type="text" runat="server" id="txt_srch_patient" /></td>
                        <td></td>
                        <%--<td><input type="button" runat="server" id="btnSearch" class="btn btn-info btns_text" value="SEARCH" /></td>--%>
                        <td><asp:Button runat="server" ID="btnSearch" CssClass="btn btn-info btns_text" Text="SEARCH" OnClick="btnSearch_Click"/></td>
                        <td style="width:5px"></td>
                    </tr>
                    <tr>
                        <td colspan="2"></td>
                        <td>
                        <table style="font-size:8px">
                            <tr>
                                <td>SEARCH IN:</td>
                                <td style="width:3px"></td>
                                <td><asp:RadioButton runat="server" ID="rdoLastname" /> </td>
                                <td>LAST NAME</td>
                                <td><asp:RadioButton runat="server" ID="rdoFullname" /></td>
                                <td>FULL NAME</td>
                            </tr>
                        </table>
                    </td></tr>
                    <tr><td colspan="6" class="tp_dotline"></td></tr>

                    <tr><td style="height:5px"></td></tr>
                    <tr>
                        <td></td>
                        <td colspan="4">
                            <asp:GridView runat="server" ID="gvClientNames"
                                RowStyle-Wrap ="false"
                                ShowHeader="true"
                                HeaderStyle-Height="30px"
                                Font-Names="Arial,Sans-Serif"
                                CellPadding="4"
                                ForeColor="#333333"
                                GridLines="None"
                                RowHeaderColumn="1" 
                                Width="100%"

                                BackColor="White" 
                                Font-Size="10px"
                                AlternatingRowStyle-BackColor="AliceBlue"

                                AutoGenerateColumns="False" 
                                ShowHeaderWhenEmpty="True" 
                                HeaderStyle-BackColor="#507CD1"
                                HeaderStyle-ForeColor="White">

                                <Columns>
                                    <%--<asp:BoundField DataField="claim_no" HeaderText="CLAIM NO" />--%>
                                    <asp:BoundField DataField="policy_no" HeaderText="POLICY NO" />
                                    <asp:BoundField DataField="name" HeaderText="NAME" HeaderStyle-HorizontalAlign="Left" />
                                </Columns>

                            </asp:GridView>
                        </td>
                        <td></td>
                    </tr>
                    <tr><td style="height:5px"></td></tr>
                    <tr><td colspan="6" class="tp_dotline"></td></tr>
                    <tr><td colspan="5" style="text-align:right"><input type="button" runat="server" id="btnSelName" class="btn btn-info btns_text" value="SELECT NAME" /> </td></tr>
                </table>

                <div runat="server" id="divMedHistory">
                    <asp:UpdatePanel runat="server" ID="upMedHistory"><ContentTemplate>
                    <table runat="server" id="tblMedHistory" style="width:100%">
                        <tr><td colspan="6" class="bt_dotline"></td></tr>
                        <tr>
                            <td></td>
                            <td colspan="2">MEDICAL HISTORY</td>
                        </tr>
                        <tr><td style="height:3px"></td></tr>
                        <tr>
                            <td></td>
                            <td colspan="4">
                                 <asp:GridView runat="server" ID="gvMedHistory"
                                    RowStyle-Wrap ="false"
                                    ShowHeader="true"
                                    HeaderStyle-Height="30px"
                                    Font-Names="Arial,Sans-Serif"
                                    CellPadding="4"
                                    ForeColor="#333333"
                                    GridLines="None"
                                    RowHeaderColumn="1" 
                                    Width="100%"

                                    BackColor="White" 
                                    Font-Size="10px"
                                    AlternatingRowStyle-BackColor="AliceBlue"

                                    AutoGenerateColumns="False" 
                                    ShowHeaderWhenEmpty="True" 
                                    HeaderStyle-BackColor="#507CD1"
                                    HeaderStyle-ForeColor="White">

                                    <Columns>
                                        <asp:BoundField DataField="claim_no" HeaderText="CLAIM NO" />
                                        <asp:BoundField DataField="policy_no" HeaderText="POLICY NO" />
                                        <asp:BoundField DataField="diagnosis" HeaderText="DIAGNOSIS" />
                                        <asp:BoundField DataField="date" HeaderText="DATE" />
                                    </Columns>

                                </asp:GridView>
                            </td>
                        </tr>

                        <tr><td style="height:5px"></td></tr>
                        <tr><td colspan="5" class="tp_dotline"></td></tr>
                        <tr><td colspan="5" style="text-align:right"><input type="button" runat="server" id="btnOpenClaim" class="btn btn-info btns_text" value="OPEN CLAIM" /> </td></tr>

                        <tr><td style="height:10px"></td></tr>
                    </table>
                    </ContentTemplate>
                    <%--<Triggers>
                        <asp:AsyncPostBackTrigger ControlID="imgSearchPrincipal" />
                    </Triggers>--%>
                    </asp:UpdatePanel>
                </div>

            </td></tr></table>    

        </asp:Panel>    
        <%--<asp:HiddenField ID="hfClientID" runat="server" />
        <asp:HiddenField ID="hfOtherFeeID" runat="server" />
        <asp:HiddenField ID="hfOtherDocID" runat="server" />

        <%--<ajaxToolkit:ModalPopupExtender ID="pnlPolicyLogin_Ex" runat="server" TargetControlID="pnlPolicyLogin_ModalEx_Ctrl" PopupControlID="pnlPolicyLogin" BackgroundCssClass="modalLogin" Enabled="True" />--%>

        <ajaxToolkit:ModalPopupExtender runat="server" ID="pnlMedSrchPrincipal_Ext" TargetControlID="imgSearchPrincipal" PopupControlID="pnlMedSearch" Enabled="true" ></ajaxToolkit:ModalPopupExtender>
        <ajaxToolkit:ModalPopupExtender runat="server" ID="pnlMedSrchPatient_Ext" TargetControlID="imgSearchPatient" PopupControlID="pnlMedSearch" Enabled="true" ></ajaxToolkit:ModalPopupExtender>

    </div>

This window pop-ups just fine. But the problem is I need to hide the tblMedHistory when the user clicks the imagebutton (imgSearchPrincipal). But if the user clicks a different imagebutton, I need to display the tblMedHistory back as it pops up. I can't get to hide the table when the div/panel is being called by the popextender. Any workaround?

Thanks,


Solution

  • I think I've finally solved this issue. Instead of pointing the TargetControlID of the ModalPopUpExtender to the image button that also triggers the visibility of the table, I reference the TargetControlID to a hidden field, so now the imagebutton controls the visibility of the table as well as the popup through codebehind without the use of the updatepanel