Click to See Complete Forum and Search --> : ModalPopupExtender ajax control


mayanksrmcem
10-21-2008, 12:57 AM
hi,

i'm using ModalPopupExtender control in my page which show a popup.
but in this case parent and child both contents are in same page.

I would prefer to have the content displayed in the modal popup represent the source of another page or user control.

have you any idea about it.

please help...

thanx

chazzy
10-21-2008, 06:32 AM
you are probably telling the control to use the same path (you didn't post any code, so that's my shot in the dark)

mayanksrmcem
10-21-2008, 06:55 AM
I'm sending my my code to you.
in my code i'm generating a grid view which showes countries list.
and if you click on any contry name, a popup(modalPopupExteder) generate , which showes the cities list of that country.
now i'm using a single page for this work.
the sample of my code is as followes :

page name : Default.aspx

//////////////////// Original Code /////////////////////////////////

<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<%--Countries Display--%>
<asp:Label ID="lblCountries" runat="server" Text="Countries" SkinID="Heading"></asp:Label><br />
<asp:UpdatePanel ID="upCountries" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="Id"
DataSourceID="ObjectDataSource1" OnSelectedIndexChanging="GridView1_SelectedIndexChanging">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name">
<ItemStyle HorizontalAlign="Left" Width="80%" />
<HeaderStyle HorizontalAlign="Left" Width="80%" />
</asp:BoundField>
<asp:TemplateField>
<ItemStyle HorizontalAlign="Center" Width="20%" />
<HeaderStyle HorizontalAlign="Center" Width="20%" />
<ItemTemplate>
<asp:ImageButton ID="showCities" CommandName="Select" runat="server" ImageUrl="~/images/add_details.gif" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="GetCountries" TypeName="ModalPopupTableAdapters.CountriesTableAdapter">
</asp:ObjectDataSource>

<%--Cities Popup Display--%>
<asp:Button id="btnShowPopup" runat="server" style="display:none" OnClick="btnShowPopup_Click" />
<cc1:ModalPopupExtender ID="mdlPopup" runat="server" TargetControlID="btnShowPopup" PopupControlID="pnlCities"
CancelControlID="btnClose" BackgroundCssClass="modalBackground"></cc1:ModalPopupExtender>
<asp:Panel ID="pnlCities" runat="server" style="display:none;" SkinID="PopUpPanel">
<asp:UpdatePanel ID="upCities" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="lblCities" runat="server" Text="Cities" SkinID="Heading"></asp:Label><br />
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" DataKeyNames="Id" Width="50%">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name">
<ItemStyle HorizontalAlign="Left" />
<HeaderStyle HorizontalAlign="Left" />
</asp:BoundField>
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="odsCities" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="GetCitiesByCountryId" TypeName="ModalPopupTableAdapters.CitiesTableAdapter">
<SelectParameters>
<asp:Parameter Name="countryId" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
</ContentTemplate>
</asp:UpdatePanel>
<div style="text-align: right; width: 100%; margin-top: 5px;">
<asp:Button ID="btnClose" runat="server" Text="Close" Width="50px" OnClick="btnClose_Click" />
</div>
</asp:Panel>
</div>

/////////////////////// End Original Code ///////////////////////////////////

here i'm using only one page i.e. "Default.aspx"
but i want the code in to two different pages.
one for countries list and other for city list.
because i want to call this city list from any where in the project...

like followes......

/////////////////////////// Required Code Sample ///////////////////

page name : Default.aspx

<asp:Label ID="lblCountries" runat="server" Text="Countries" SkinID="Heading"></asp:Label><br />
<asp:UpdatePanel ID="upCountries" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="Id"
DataSourceID="ObjectDataSource1" OnSelectedIndexChanging="GridView1_SelectedIndexChanging">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name">
<ItemStyle HorizontalAlign="Left" Width="80%" />
<HeaderStyle HorizontalAlign="Left" Width="80%" />
</asp:BoundField>
<asp:TemplateField>
<ItemStyle HorizontalAlign="Center" Width="20%" />
<HeaderStyle HorizontalAlign="Center" Width="20%" />
<ItemTemplate>
<asp:ImageButton ID="showCities" CommandName="Select" runat="server" ImageUrl="~/images/add_details.gif" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="GetCountries" TypeName="ModalPopupTableAdapters.CountriesTableAdapter">
</asp:ObjectDataSource>


page name : popup.aspx

<asp:Button id="btnShowPopup" runat="server" style="display:none" OnClick="btnShowPopup_Click" />
<cc1:ModalPopupExtender ID="mdlPopup" runat="server" TargetControlID="btnShowPopup" PopupControlID="pnlCities"
CancelControlID="btnClose" BackgroundCssClass="modalBackground"></cc1:ModalPopupExtender>
<asp:Panel ID="pnlCities" runat="server" style="display:none;" SkinID="PopUpPanel">
<asp:UpdatePanel ID="upCities" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="lblCities" runat="server" Text="Cities" SkinID="Heading"></asp:Label><br />
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" DataKeyNames="Id" Width="50%">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name">
<ItemStyle HorizontalAlign="Left" />
<HeaderStyle HorizontalAlign="Left" />
</asp:BoundField>
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="odsCities" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="GetCitiesByCountryId" TypeName="ModalPopupTableAdapters.CitiesTableAdapter">
<SelectParameters>
<asp:Parameter Name="countryId" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
</ContentTemplate>
</asp:UpdatePanel>
<div style="text-align: right; width: 100%; margin-top: 5px;">
<asp:Button ID="btnClose" runat="server" Text="Close" Width="50px" OnClick="btnClose_Click" />
</div>
</asp:Panel>

/////////////////////// End Required Code Sample //////////////////////////////

My problem is that how can i set "TargetControlID" of ModalPopupExtender control which is not in the same page.

have you any idea about it..............?
thanx...