I have modal popup extender in my ASP.NET webforms application. Can I reuse the same modal popup extender in all webforms to accomplish common search?
If possible where can I place the modal popup extender? Anyone help me please
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
<asp:Button runat="server" ID="btnTarget" Style="display: none;" />
<cc1:ModalPopupExtender runat="server" ID="mp1" PopupControlID="SearchPanel" TargetControlID="btnTarget"
CancelControlID="ImgBtnCloseSearch" BackgroundCssClass="modalBackground">
</cc1:ModalPopupExtender>
<asp:Panel runat="server" ID="PanelSearch" OnLoad="PanelSearch_Load">
<div id="SearchPanel" runat="server" class="modalPopup">
<asp:ImageButton runat="server" ImageUrl="~/Images/CloseButton.png" ID="ImgBtnCloseSearch" CssClass="Modal-Close" />
<div class="row">
<div style="margin-left: auto; margin-right: auto; text-align: center; margin-top: 12px;">
<asp:Label runat="server" Text="Search Text" ID="lblKey" Style="margin-left: 5px;"></asp:Label>
<asp:TextBox runat="server" ID="txtKey" Style="margin-left: 5px;" Width="200" Height="25"></asp:TextBox>
<asp:Button Text="Go" runat="server" CssClass="Btn-Go" ID="BtnGoSearch" OnClick="BtnGoSearch_Click" Height="26" />
<br />
<div class="Div-DisplaySearchGrid">
<asp:GridView ID="GrdDataSearch" runat="server" AutoGenerateColumns="false" OnRowDataBound="GrdDataSearch_RowDataBound"
Font-Size="11px" HeaderStyle-BackColor="#c8c8c8" FooterStyle-BackColor="#f0f1f3" BackColor="whitesmoke"
DataKeyNames="PK" BorderColor="black" CellPadding="3" ShowFooter="True" ShowHeaderWhenEmpty="true">
</asp:GridView>
<%-- <asp:GridView ID="GvSearchData" runat="server" ShowHeaderWhenEmpty="true" AllowSorting="true" AllowPaging="True" AutoGenerateColumns="False" Font-Size="11px" HeaderStyle-BackColor="#c8c8c8" FooterStyle-BackColor="#f0f1f3" BackColor="whitesmoke" DataKeyNames="PK" BorderColor="black"
EmptyDataText="No rows to display"
CellPadding="3" ShowFooter="True" PageSize="10" OnPageIndexChanging="GvSearchData_PageIndexChanging" OnRowDataBound="GvSearchData_RowDataBound" OnSelectedIndexChanged="GvSearchData_SelectedIndexChanged" Style="margin-bottom: 20px; margin-top: 10px; margin-left: 2px; margin-right: 2px;">
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id" HeaderStyle-Width="40" Visible="false" />
<asp:BoundField DataField="Code" HeaderText="Code" HeaderStyle-Width="120" />
<asp:BoundField DataField="Description" HeaderText="Description" HeaderStyle-Width="280" />
<asp:BoundField DataField="Category" HeaderText="Category" HeaderStyle-Width="200" />
<asp:BoundField DataField="SubCategory" HeaderText="SubCategory" HeaderStyle-Width="200" />
</Columns>
</asp:GridView>--%>
</div>
<br />
</div>
<asp:HiddenField runat="server" ID="hdnSearchFlag" />
</div>
</div>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
You could try adding it as a user control then declaring the control on the pages where you need.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0