Jan 11, 2017, 5:30 PM
[CLOSED] UserControlLoader handling events define in User Control
Since moving the UserControl into a UserControlLoader, my events are not firing. I have created a sample as best I can to show the issue. Basically my UserControl raises an event that the containing page handles, which worked prior to moving it into a UserControlLoader for the issue linked below. I think the problem is basically before I had the actual user control defined in the page and now I just have a reference to the UserControlLoader and not the actual UserControl. Just not sure how to define the handler for the event in the containing page.
This is a result of having to use UserControlLoader instead of a defined user control inside of a Content tag, see:
http://forums.ext.net/showthread.php...a-user-control
UserControl
This is a result of having to use UserControlLoader instead of a defined user control inside of a Content tag, see:
http://forums.ext.net/showthread.php...a-user-control
UserControl
<%@ Control Language="vb"%>
<script runat="server">
Partial Public Class QSearch
Inherits System.Web.UI.UserControl
Public Event Selected As EventHandler
Public Class QuickSearchEventArgs
Inherits Ext.Net.DirectEventArgs
Public SelectedEntity As String
Public Sub New(extraParams As Ext.Net.ParameterCollection)
MyBase.New(extraParams)
End Sub
End Class
Public Sub Results_Select(ByVal sender As Object, ByVal e As Ext.Net.DirectEventArgs)
Dim value = e.ExtraParams("Key")
Dim params As New Ext.Net.ParameterCollection()
params.Add(New Ext.Net.Parameter("SameWindow", True))
Dim args As New QuickSearchEventArgs(params) With {
.SelectedEntity = "x"
}
RaiseEvent Selected(Me, args)
End Sub
End Class
</script>
<ext2:ComboBox
ID="Results"
runat="server"
ValueField="Key"
TypeAhead="false"
LoadingText="Searching..."
HideTrigger="true"
EmptyText="Type to Search"
QueryDelay="1500"
QueryCaching="false"
MinChars="1"
Border="false"
Width="920"
Height="38">
<Store>
<ext2:Store ID="Store1" runat="server">
<Model>
<ext2:Model runat="server" IDProperty="Value">
<Fields>
<ext2:ModelField Name="Text" />
<ext2:ModelField Name="Value" />
</Fields>
</ext2:Model>
</Model>
</ext2:Store>
</Store>
<Items>
<ext2:ListItem Text="Text1" Value="1" />
<ext2:ListItem Text="Text2" Value="2" />
<ext2:ListItem Text="Text3" Value="3" />
</Items>
<DirectEvents>
<Select OnEvent="Results_Select">
<EventMask ShowMask="true" Target="Page" />
<ExtraParams>
<ext2:Parameter Name="Key" Value="testing" Mode="Raw" />
</ExtraParams>
</Select>
</DirectEvents>
</ext2:ComboBox>
Main page<%@ Page Language="vb" %>
<script runat="server">
Protected WithEvents QuickSearch As Qsearch???
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Private Sub QuickSearch_Selected(sender As Object, e As QSearch.QuickSearchEventArgs) Handles QuickSearch.Selected
Ext.Net.X.AddScript("alert('test');")
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Simple Combo</title>
</head>
<body>
<ext2:ResourceManager ID="ResourceManager" runat="server" />
<ext2:Window ID="Window1" runat="server" Visible="true" Maximized="true" Padding="5" Resizable="true" MinHeight="700" MinWidth="500" Closable="false">
<TopBar>
<ext2:Toolbar ID="Toolbar1" runat="server">
<Items>
<ext2:Button ID="QuickLaunchReport" runat="server" Text="This does not work" >
<Menu>
<ext2:Menu ID="QuickLaunchReportMenu" runat="server" RenderToForm="true" Width="450" ShowSeparator="false">
<Items>
<ext2:Panel runat="server">
<Items>
<ext2:UserControlLoader runat="server" ID="UCQuickSearch" UserControlID="QuickSearch" Path="QSearch.ascx"></ext2:UserControlLoader>
</Items>
</ext2:Panel>
</Items>
</ext2:Menu>
</Menu>
</ext2:Button>
</Items>
</ext2:Toolbar>
</TopBar>
<Items>
<ext2:Panel ID="pnlSetDefaults" runat="server">
<Items>
</Items>
</ext2:Panel>
</Items>
</ext2:Window>
</body>
</html>
Last edited by fabricio.murta; Feb 10, 2017 at 8:12 PM.