PDA

View Full Version : [CLOSED] ASPX ---> ASCX ---> ASCX (in Windows) :: Open new Windows with dynamic ASCX



Mario
Dec 06, 2014, 9:51 AM
Hi,

I have an ASPX page (WebForm1) that loads dinamically a ASCX control (WebUserControl1).
In this ASCX (WebUserControl1), I want show a modal Window that show a second ASCX control (Test) inside.

Can you help me?

The code:


WebForm1.aspx


<%@ Page Language="vb" %>

<%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>

<script runat="server">
Protected Sub Page_Load(sender As Object, e As EventArgs)
Dim Applicazione As New Ext.Net.UserControlLoader
Applicazione.ID = "Applicazione1"
Applicazione.Path = "WebUserControl1.ascx"
PanelApplicazione.Items.Clear()
PanelApplicazione.Items.Add(Applicazione)
End Sub
</script>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">

<ext:ResourceManager runat="server" ID="ResourceManager1" />

<ext:Viewport runat="server" ID="Viewport1">
<LayoutConfig>
<ext:VBoxLayoutConfig Align="Center" />
</LayoutConfig>

<Items>
<ext:Panel ID="PanelApplicazione" runat="server" Flex="1" Width="1000" Border="false" PaddingSpec="5 0 5 0" Layout="FitLayout" />
</Items>

</ext:Viewport>

</form>
</body>
</html>



WebUserControl1.ascx


<%@ Control Language="vb" %>

<script runat="server">
Protected Sub Button1_Click(sender As Object, e As Ext.Net.DirectEventArgs)
Dim Controllo As New Ext.Net.UserControlLoader
Controllo.ID = "Test1"
Controllo.Path = "Test.ascx"

Dim Finestra As New Ext.Net.Window
Finestra.ID = "FinestraTest1"
Finestra.Items.Add(Controllo)

Finestra.Show()
End Sub
</script>

<ext:Panel ID="Panel1" runat="server">
<Items>
<ext:Button runat="server" ID="Button1" IDMode="Static" Text="GO !">
<DirectEvents>
<Click OnEvent="Button1_Click" />
</DirectEvents>
</ext:Button>
</Items>
</ext:Panel>



Test.ascx


<%@ Control Language="vb" %>

<ext:Panel ID="Panel1" runat="server" >
<Items>
<ext:Label runat="server" ID="Label1" Text="Hello World !" />
</Items>
</ext:Panel>



If you run the code and click on "GO !" it should show a modal window with the label "Hello World !" ... but nothing appears.

Daniil
Dec 07, 2014, 11:00 PM
Hi Mario,


I want show a modal Window that show a second ASCX control (Test) inside.

As far as I can understand you try to show it somehow. So, what does happen with your attempt? Does it not work? Is there any error or exception thrown?

Also I would like to recommend you to use

<script runat="server">
</script>
for code behind. It would help to provide us with standalone examples which we can easily copy, paste and run without any changes from our side.

In this case for the Page directive you should leave only the Language setting.

<%@ Page Language="VB" %>

Please see Example (Very Helpful) here.
Forum Guidelines For Posting New Topics (http://forums.ext.net/showthread.php?3440)

We would appreciate if you edit the code samples in the original post.

Mario
Dec 08, 2014, 9:16 AM
I edited the original post.
I await the help.
Thanks Danill.

Daniil
Dec 08, 2014, 2:14 PM
Thank you.

You should also render a Window.

Protected Sub Button1_Click(sender As Object, e As Ext.Net.DirectEventArgs)
...

Finestra.Render()
Finestra.Show()
End Sub

See also
http://examples2.ext.net/#/search/xrender

Mario
Dec 08, 2014, 2:43 PM
Thank you Danill.
Problem solved: you're always very helpful!