locked
ModalPopupExtender keep open RRS feed

  • Question

  • User1510859543 posted

    I have a ModalPopupExtender on a master page that makes a Panel visible when I click a button.  I have a checkbox in the Panel that is used in the query to display different rows in the GridView inside the Panel.  However, when I click the checkbox the panel disappears.  How do I keep the Panel visible and just Databind the GridView?  Code is below.

                        <asp:Button ID="LBtnChooseClient" runat="server" Text="Select or add a Client" Font-Size="Medium"></asp:Button>
                        <asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" PopupControlID="PanelPickPatient" 
                            TargetControlID="LBtnChooseClient" BackgroundCssClass="popUpStyle" 
                            DropShadow="True" RepositionMode="RepositionOnWindowResize">
                        </asp:ModalPopupExtender> 
    
    
        <asp:Panel ID="PanelPickPatient" runat="server" style="display:none;z-index:100000" BackColor="#FFFFFF" ScrollBars="Auto" Height="400">
            <table width="400" style="background-color: #FFFFFF">
                <tr>
                    <td>
                        <asp:Label ID="LblSelect" runat="server" Text="Select from list or " Font-Size="10pt" ForeColor="Blue"></asp:Label>
                        <asp:LinkButton ID="LBtnNewClient" runat="server" Text="Add a Client"></asp:LinkButton>
                    </td>
                    <td align="center">
                        <asp:CheckBox ID="ckActiveOnly" runat="server" Text="Active" 
                            Checked="True" AutoPostBack="True" />
                    </td>
                    <td align="right">
                        <asp:LinkButton ID="LBtnCancelSelect" runat="server" Text="Cancel"></asp:LinkButton>
                    </td>
                </tr>
            </table>
            
            <asp:GridView ID="gvPatients" runat="server" AutoGenerateColumns="False" 
                DataKeyNames="PatientID" DataSourceID="SqlselPatientsOneorg" 
                CellPadding="4" ForeColor="#333333" GridLines="None" ShowFooter="True">
                <RowStyle  CssClass="gridrow" />
                <Columns>
                    <asp:TemplateField HeaderText="Client Name">
                        <ItemTemplate>
                            <asp:LinkButton ID="LBtnLastFirst" runat="server" ToolTip="click to select" 
                                Text='<%# Eval("LastFirst") %>' CausesValidation="False" CommandName="Select">
                            </asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="DOB" DataFormatString="{0:d}" HeaderText="DOB" 
                        SortExpression="DOB" />
                    <asp:TemplateField HeaderText="Unverified Meals" ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <asp:LinkButton ID="LBtnUnverifiedMeals" runat="server" Text='<%# Eval("UnverifiedMeals") %>' 
                                CommandName="unmeals" CommandArgument='<%# Eval("PatientID") %>'></asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Unverified Snacks" ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <asp:LinkButton ID="LBtnUnverifiedSnacks" runat="server" Text='<%# Eval("UnverifiedSnacks") %>' 
                                CommandName="unsnacks" CommandArgument='<%# Eval("PatientID") %>'></asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:Label ID="LblPatientID" runat="server" Text='<%# Eval("PatientID") %>' CssClass="Hide"></asp:Label>    
                            <asp:Label ID="LblAge" runat="server" Text='<%# Eval("Age") %>' CssClass="Hide"></asp:Label>    
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <FooterStyle CssClass="gridfoot" />
                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                <SelectedRowStyle BackColor="#FFFF99" Font-Bold="True" ForeColor="#333333" />
                <HeaderStyle CssClass="gridhead" />
                <EditRowStyle BackColor="#999999" />
                <AlternatingRowStyle CssClass="gridaltrow" />
            </asp:GridView>
            
            <asp:SqlDataSource ID="SqlselPatientsOneorg" runat="server" 
                ConnectionString="<%$ ConnectionStrings:KetodataConnectionString %>" 
                SelectCommand="kd_selPatientsOneOrg" SelectCommandType="StoredProcedure">
                <SelectParameters>
                    <asp:CookieParameter Name="OrgID" CookieName="OrgID" Type="Int32" />
                    <asp:ControlParameter Name="ActiveOnly" ControlID="ckActiveOnly" Type="Boolean" />
                </SelectParameters>
            </asp:SqlDataSource>
        </asp:Panel>

    Monday, July 28, 2014 5:37 PM

Answers

  • User177399542 posted

    Hi dlchase: You need to reopen your modal popup after page reload. For this you need to create OnCheckedChanged event of your checkbox.

     <asp:CheckBox ID="ckActiveOnly" runat="server" OnCheckedChanged="ckActiveOnly_CheckedChanged" Text="Active"
                Checked="True" AutoPostBack="True" />


    And within this event open your modal popup:

     protected void ckActiveOnly_CheckedChanged(object sender, EventArgs e)
        {
            ModalPopupExtender1.Show();
        }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 29, 2014 12:27 AM