Jan 25, 2013, 11:53 PM
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
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.vbImports 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.vbImports 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.