PDA

View Full Version : [CLOSED] How to load IFrame to parent page



bayoglu
Feb 07, 2013, 4:43 AM
Hello,

Brief scenario:
MainPage (say Page0) has a command loading an aspx page (say Page1) in a modal window. Page1 also containts a command to load another aspx page (say Page2) again in a modal window. All load modes are set as "LoadMode.Frame".

Requirement: If Page1 is browsed directly, then it is okay to load Page2 into Page1. If Page1 is already loaded as iFrame in Page0, then I want Page2 to load in Page0 instead of Page1. Is this achievable?

Sample codes below:

Page0 aspx:


<%@ Page Language="C#" %>
<%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>

<script runat="server">
protected void showPage1(object sender, DirectEventArgs e)
{
Window win = new Window();
ComponentLoader pLoader = new ComponentLoader();
win.Title = "Page #1";
win.ID = "page1";
win.Width = Unit.Pixel(300);
win.Height = Unit.Pixel(300);
win.Modal = true;
pLoader.Url = "page1.aspx";
pLoader.Mode = LoadMode.Frame;
win.Loader = pLoader;
win.Render(this.Form);
}
</script>

<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
<title>"Load window from window"</title>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager2" runat="server"/>
<ext:Button ID="Button1" runat="server" Text="Show Page #1">
<DirectEvents>
<Click OnEvent="showPage1"></Click>
</DirectEvents>
</ext:Button>
</form>
</body>
</html>


Page1 aspx:


<%@ Page Language="C#" %>
<%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>

<script runat="server">
protected void showPage2(object sender, DirectEventArgs e)
{
Window win = new Window();
ComponentLoader pLoader = new ComponentLoader();
win.Title = "Page #2";
win.ID = "page2";
win.Width = Unit.Pixel(100);
win.Height = Unit.Pixel(100);
win.Modal = true;
pLoader.Url = "http://ext.net";
pLoader.Mode = LoadMode.Frame;
win.Loader = pLoader;
win.Render(this.Form);
}
</script>

<!DOCTYPE html>

<html>
<head id="Head1" runat="server">
</head>
<body>
<form id="form1" runat="server">
</div>
<ext:ResourceManager ID="ResourceManager2" runat="server"/>
<ext:Button ID="Button1" runat="server" Text="Show Window #2">
<DirectEvents>
<Click OnEvent="showPage2"></Click>
</DirectEvents>
</ext:Button>
</form>
</body>
</html>


Page2 is http://ext.net

Daniil
Feb 07, 2013, 5:56 AM
Hi @bayoglu,

If I correctly understand you need to render a Window from a child page to its parent. Correct?

You could organize a DirectMethod on the parent page and call it from the child page this way.

parent.App.direct.CreateWindow();

Hope this helps.

bayoglu
Feb 07, 2013, 4:33 PM
Hi @bayoglu,

If I correctly understand you need to render a Window from a child page to its parent. Correct?

You could organize a DirectMethod on the parent page and call it from the child page this way.

parent.App.direct.CreateWindow();

Hope this helps.

Hello Daniil,

Yes it might be the solution. By the way, I need more advice. Below is the list of my questions.

1) Windows are rendered with Direct Events. Is it possible to fire direct event of a child page from the parent page? Otherwise, I will have to change those direct events to direct method which I would not preferably do.

2) How can I understand that Page1 rendering Page2 is also a child window in Page 0 (case 1) or a stand alone page (case 2)? If I can do that, I may initiate direct event regularly in case 2 and call direct method of the parent page in case 1.

Current situation:
Page0 Direct Event > Loads Page 1 IFrame window.
Page1 Direct Event > Loads Page 2 IFrame window.

In the current situation, If Page 1 is already rendered as IFrame in Page0, I want to render Page2 in Page0 when trigerring the direct event of Page1. If Page1 is a standalone page, then Page2 will be rendered as a child of it (as it is now). So I need to be able to understand whether Page1 is IFrame window or a fully rendered page.

3) May this be an alternate solution or is it a buggy one?
Organize a url parameter for Page1 to indicate calling party. If parameter says "0", disable/remove direct event on Page 1 and call direct method on Page 0 when clicked to load Page2. If parameter says "1", leave direct event on Page 1 as it is.


Can you advice more on the issue?
Thank you very much.

bayoglu
Feb 07, 2013, 6:01 PM
Hi @bayoglu,

If I correctly understand you need to render a Window from a child page to its parent. Correct?

You could organize a DirectMethod on the parent page and call it from the child page this way.

parent.App.direct.CreateWindow();

Hope this helps.

Hello Daniil,

Example code is below. How can I disable/enable direct event and/or direct method depending on a case selection url parameter.



<ext:CommandColumn ID="CommandColumn1" runat="server" Header="Operations" Flex="1" Pack="Center">
<Commands>
<ext:GridCommand CommandName="gridCommand" Text="Load it" StandOut="true" />
</Commands>
<PrepareToolbar Fn="prepareColumnCommand"/>
<Listeners>
<Command Handler="parent.App.direct.directMethodHandler(record.data. Name,record.data.ID)">
</Command>
</Listeners>
<DirectEvents>
<Command OnEvent="directEventHandler">
<ExtraParams>
<ext:Parameter Name="ID" Value="record.data.ID" Mode="Raw" Encode="false" />
<ext:Parameter Name="Name" Value="record.data.Name" Mode="Raw" Encode="true" />
</ExtraParams>
</Command>
</DirectEvents>
</ext:CommandColumn>


Thanks.

bayoglu
Feb 07, 2013, 9:27 PM
Hello Daniil,

Example code is below. How can I disable/enable direct event and/or direct method depending on a case selection url parameter.



<ext:CommandColumn ID="CommandColumn1" runat="server" Header="Operations" Flex="1" Pack="Center">
<Commands>
<ext:GridCommand CommandName="gridCommand" Text="Load it" StandOut="true" />
</Commands>
<PrepareToolbar Fn="prepareColumnCommand"/>
<Listeners>
<Command Handler="parent.App.direct.directMethodHandler(record.data. Name,record.data.ID)">
</Command>
</Listeners>
<DirectEvents>
<Command OnEvent="directEventHandler">
<ExtraParams>
<ext:Parameter Name="ID" Value="record.data.ID" Mode="Raw" Encode="false" />
<ext:Parameter Name="Name" Value="record.data.Name" Mode="Raw" Encode="true" />
</ExtraParams>
</Command>
</DirectEvents>
</ext:CommandColumn>


Thanks.

I managed to do it using Before event of direct event depending on a ext:hidden value. If value is say "0" Before event returns zero and parent direct method is called by listener. If value is "1", Before event returns false and parent direct method is called. Please tell me if this solution is wrong by architect. Thanks.

geoffrey.mcgill
Feb 07, 2013, 9:43 PM
Please maintain one topic per thread.

The original question in this thread has been answered. Marking thread a [CLOSED].

bayoglu
Feb 07, 2013, 11:56 PM
Please maintain one topic per thread.

The original question in this thread has been answered. Marking thread a [CLOSED].

No problem left at all, will start a new threat if I feel the solution I implemented causes problems.