Sep 07, 2010, 10:39 AM
[CLOSED] Problem rendering usercontrol within BorderLayout at runtime
I have a scenario where I'm loading a webusercontrol (ParentControl.ascx) onto a webform (WebForm2.aspx) at runtime. ParentControl.ascx has a button contained within a panel. On the DirectEvent click of the button I'm calling a DirectMethod that will load another usercontrol inside the ParentControl panel. This is achieved by adding the ChildControl.ascx to the ParentControl.ascx ContentControls collection and then calling Render on the Panel. This seems to functionality currently however, if I change ParentControl.ascx to contain a BorderLayout and try to add ChildControl.ascx to one of the Panels, the control does not appear to load.
Does anyone have any ideas?
Below I've listed the entire working example and also the changes required to break the example. If I've not made my issues clear then please reply and I'll provide further details.
Thanks,
GavinR
Working Example
Does anyone have any ideas?
Below I've listed the entire working example and also the changes required to break the example. If I've not made my issues clear then please reply and I'll provide further details.
Thanks,
GavinR
Working Example
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm2.aspx.vb" Inherits="Horizon.AppServers.ContractorHelpdesk.WebForm2" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<ext:ResourceManager ID="rm" runat="server" />
<ext:Viewport ID="vp" runat="server" Layout="Fit">
</ext:Viewport>
</div>
</form>
</body>
</html>
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="ParentControl.ascx.vb"
Inherits="Horizon.AppServers.ContractorHelpdesk.ParentControl" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<ext:ResourceManagerProxy ID="rmp" runat="server" />
<ext:Panel ID="Panel1" runat="server" Height="300" Title="Title">
<Items>
<ext:Button ID="Button1" runat="server" Text="Submit">
<DirectEvents>
<Click OnEvent="Button_Click" />
</DirectEvents>
</ext:Button>
</Items>
</ext:Panel>
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="ChildControl.ascx.vb" Inherits="Horizon.AppServers.ContractorHelpdesk.ChildControl" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<ext:Button ID="Button1" runat="server" Text="Submit">
</ext:Button>
Public Class WebForm2
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.vp.ContentControls.Add(LoadControl("ParentControl.ascx"))
End Sub
End Class
Public Class ParentControl
Inherits System.Web.UI.UserControl
<Ext.Net.DirectMethod()> _
Protected Sub Button_Click(ByVal sender As Object, ByVal e As Ext.Net.DirectEventArgs)
Panel1.ContentControls.Add(LoadControl("ChildControl.ascx"))
Panel1.Render(Me)
End Sub
End Class
Breaking Change<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="ParentControl.ascx.vb"
Inherits="Horizon.AppServers.ContractorHelpdesk.ParentControl" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<ext:ResourceManagerProxy ID="rmp" runat="server" />
<%--<ext:Panel ID="Panel1" runat="server" Height="300" Title="Title">
<Items>
<ext:Button ID="Button1" runat="server" Text="Submit">
<DirectEvents>
<Click OnEvent="Button_Click" />
</DirectEvents>
</ext:Button>
</Items>
</ext:Panel>--%>
<ext:Panel ID="Panel5" runat="server" Height="300" Title="Title">
<Items>
<ext:BorderLayout ID="BorderLayout1" runat="server">
<West Collapsible="true" Split="true">
<ext:Panel ID="Panel1" runat="server" Title="West" Width="175">
</ext:Panel>
</West>
<Center>
<ext:Panel ID="Panel2" runat="server" Title="Center">
<Items>
<ext:Button ID="Button1" runat="server" Text="Submit">
<DirectEvents>
<Click OnEvent="Button_Click" />
</DirectEvents>
</ext:Button>
</Items>
</ext:Panel>
</Center>
<East Collapsible="true" Split="true">
<ext:Panel ID="Panel3" runat="server" Title="East" Width="175">
</ext:Panel>
</East>
<South Collapsible="true" Split="true">
<ext:Panel ID="Panel4" runat="server" Height="150" Title="South">
</ext:Panel>
</South>
</ext:BorderLayout>
</Items>
</ext:Panel>