0

I have an asp.net gridview in a javascript modal. If there are multiple pages in the gridview and I click on the next page (lets say 2 pages), the modal disappears. I want it to persist while the user pages though the list. Any help would be appreciated.

Javascript:

function ShowSelRecipModal(msgIndex, intGridNum) {
    document.getElementById('hidMsgSelected').value = msgIndex;
    document.getElementById('hidGridUsed').value = intGridNum;

    Popup.showModal('modalSelRecipPopup', null, null, {
        'screenColor': '#99ff99',
        'screenOpacity': .6
    });

    return false;
}

HTML:

<div class="popUpForm" id="modalSelRecipPopup" style="border: 3px solid black; background-color: #ffffff; padding: 25px; display: none;">
    <div class="popUpRow">
        <asp:GridView ID="grdSelMsgList" runat="server" Width="400px" AllowPaging="True" PageSize="6" OnPageIndexChanging="grdSelMsgList_PageIndexChanging">
            <AlternatingRowStyle BackColor="#CCFFCC" />
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:CheckBox ID="chkSelect" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <EditRowStyle BackColor="#FFCCCC" />
        </asp:GridView>
    </div>
    <div class="popUpRow">
        <asp:Label ID="Label3" runat="server" />
    </div>
    <asp:Button ID="btnSelRecip" runat="server" Text="OK" BackColor="White" ForeColor="Black" OnClick="btnSelRecip_Click" />
</div>

1 Answer 1

0

What this sounds like is that your modal dialog is not being regenerated after postback. With the asp.net Gridview control, paging causes a postback, so any dynamically generated elements/controls will have to be re-added to the form/page. Some people solve this issue by placing an update panel within the container being loaded into or as a modal dialog. I've also accomplished persisting the modal dialog using true/false variables/sessions within the page_load event of the current page and the code behind of the modal form. It depends on what you feel more comfortable using, or what is necessary to use.

If you were to search this site or google using "dynamic controls lost on postback" or "jQuery modal disappears on postback" you'll surely find numerous articles, with code examples, to help you with this issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.