Error in Direct Events When Loading User Control to Desktop

  1. #1

    Error in Direct Events When Loading User Control to Desktop

    Hi ,
    I have been exploring Ext.Net examples and forums for the last two weeks, actually it's very nice. I decided to use Desktop control in my application with buttons at the top. Each button should load a user control dynamically and display it in a new window within the desktop.

    Everything is working good but the direct events in the user control produces error: "The control with ID 'ctrl1_button1' not found". The same thing when using direct methods but the ID in the message is different: "The control with ID 'ctrl1' not found".

    Actually I've searched the forum many times, I founded many results similar to may situation, I tried to implement them but couldn't succeed. I understand that dynamic controls should recreated every request as it is ASP requirement (http://forums.ext.net/showthread.php...ll=1#post60155) and I did that in Application_Load.

    Please help me.
    Thanks in Advance

    Application.aspx
    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Application.aspx.vb" Inherits="CESCWEB.Application" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html>
    <html>
    <head id="Head1" runat="server">
        <title>Application</title>
        <style>
            .add32 {background-image: url(images/32/add.gif) !important;}
        </style>
    </head>
    <body>
        <ext:resourcemanager runat="server" />
        <ext:desktop id="Desktop1" runat="server">                
            <DesktopConfig Wallpaper="resources/wallpapers/desk.jpg" ShortcutDragSelector="true">
                <ShortcutDefaults IconCls="x-default-shortcut" />
                <Content>
                    <ext:viewport id="Viewport1" runat="server" layout="border" IDMode="Explicit" >
                        <Items>    
                            <ext:Panel runat="server" Title="Menu" Height = "125px" Region="North" Collapsible="true" >
                                <TopBar>
                                    <ext:Toolbar runat="server">
                                        <Items>
                                            <ext:ButtonGroup runat="server" Title="Clipboard" Columns="3">
                                                <Items>
                                                    <ext:Button runat="server" Text="New Form" IconCls="add32" Scale="Large" IconAlign="Top" Cls="x-btn-as-arrow" RowSpan="3" OnDirectClick="newForm_Click" />
                                                </Items>
                                            </ext:ButtonGroup>       
                                        </Items>
                                    </ext:Toolbar>
                                </TopBar>
                            </ext:Panel>
                        </Items>
                    </ext:viewport>
                </Content>
            </DesktopConfig>
        </ext:desktop>
    </body>
    </html>
    Application.aspx.vb
    Imports Ext.Net
    
    Public Class Application
        Inherits System.Web.UI.Page
    
        Private Sub Application_Load(sender As Object, e As System.EventArgs) Handles Me.Load
            If IsNothing(Session("loadNewForm")) Then
                'Do Nothing
            Else
                loadNewForm()
            End If
        End Sub
        Protected Sub newForm_Click(sender As Object, e As DirectEventArgs)
            loadNewForm()
            Session.Add("loadNewForm", True)
        End Sub
    
        Private Sub loadNewForm()
            Dim win1 As New Window()
            win1.ID = "win1"
            Dim ctrl1 As Control = LoadControl("UserControl.ascx")
            ctrl1.ID = "ctrl1"
            win1.ContentControls.Add(ctrl1)
            win1.Show()
            Desktop1.CreateWindow(win1)
        End Sub
    End Class
    UserControl.ascx
    <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="UserControl.ascx.vb" Inherits="CESCWEB.UserControl" %>
    
    <ext:button runat="server" text="Click Me!"  ID="button1" OnDirectClick="directEvent" />   
    <ext:button runat="server" text="Click Me!"  ID="button2">   
        <Listeners>
            <Click Handler="#{DirectMethods}.directMethod();" />
        </Listeners>
    </ext:button>
    <ext:TextField runat="server" ID="text1" />
    UserControl.ascx.vb
    Imports Ext.Net
    Public Class UserControl
        Inherits System.Web.UI.UserControl
    
        Protected Sub directEvent(sender As Object, e As DirectEventArgs)
            text1.Text = "Direct Event is working!"
        End Sub
    
        <DirectMethod()>
        Public Sub directMethod()
            text1.Text = "Direct Method is working!"
        End Sub
    End Class
    Last edited by Meshalawy; Jan 26, 2013 at 10:30 AM.
  2. #2
    hello,

    Can anyone help me with that ?


    Thanks

Similar Threads

  1. Replies: 1
    Last Post: Sep 22, 2012, 8:08 PM
  2. Replies: 8
    Last Post: Jan 25, 2011, 4:21 AM
  3. Replies: 5
    Last Post: Jan 19, 2011, 3:17 PM
  4. [CLOSED] Direct events in user control
    By tiramisu in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Dec 13, 2010, 11:34 AM
  5. Replies: 3
    Last Post: May 11, 2010, 10:36 AM

Tags for this Thread

Posting Permissions