Dec 09, 2014, 8:38 AM
[CLOSED] Close windows on click in UserControl loaded dynamically
I have this code:
WebForm1.aspx
If you click on "Go !" button and on "CHIUDI" button... the window closes without any problems.
BUT...
If you change the code for load User Control dinamically.....
WebUserControl1.ascx
I tried to play with the properties "ClientIDMode" and "IDMode", without success.
Help, please.
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)
Windows1.Show()
End Sub
</script>
<ext:Panel ID="Panel1" runat="server">
<Items>
<ext:Button runat="server" ID="Button1" Text="GO !" OnDirectClick="Button1_Click" />
</Items>
</ext:Panel>
<ext:Window runat="server" ID="Windows1" Hidden="true" >
<Items>
<ext:UserControlLoader Path="test.ascx" runat="server" ID="UserControlLoaderTest" />
</Items>
</ext:Window>
Test.ascx<%@ Control Language="vb" %>
<script runat="server">
Protected Sub Button2_DirectClick(sender As Object, e As DirectEventArgs)
CType(Ext.Net.X.GetCtl(Me.Parent.Parent.ID), Ext.Net.Window).Hide()
End Sub
</script>
<ext:Panel ID="Panel1" runat="server" >
<Items>
<ext:Button runat="server" ID="Button2" Text="CHIUDI" OnDirectClick="Button2_DirectClick" />
</Items>
</ext:Panel>
that work perfectly:If you click on "Go !" button and on "CHIUDI" button... the window closes without any problems.
BUT...
If you change the code for load User Control dinamically.....
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.Render()
End Sub
</script>
<ext:Panel ID="Panel1" runat="server">
<Items>
<ext:Button runat="server" ID="Button1" Text="GO !" OnDirectClick="Button1_Click" />
</Items>
</ext:Panel>
...appears "The control with ID 'ctl03_Button2' not found" error.I tried to play with the properties "ClientIDMode" and "IDMode", without success.
Help, please.
Last edited by Daniil; Dec 23, 2014 at 5:31 PM.
Reason: [CLOSED]