Sep 04, 2013, 6:53 AM
[CLOSED] Experiment with UserControlLoader to user Control instead of UserControl
I went through UserControlLoader and replaced UserControl with Control. The idea was simply to see if it would compile and run because it would allow other controls like a WebControl to load as well. The experiment worked. I'm wondering, why wouldn't you guys consider making this change?
Index: C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Ext/UserControlLoader.cs
===================================================================
--- C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Ext/UserControlLoader.cs (revision 5348)
+++ C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Ext/UserControlLoader.cs (working copy)
@@ -84,7 +84,7 @@
}
}
- private UserControl uc;
+ private Control uc;
/// <summary>
///
@@ -100,11 +100,11 @@
/// <summary>
///
/// </summary>
- public virtual List<UserControl> UserControls
+ public virtual List<Control> UserControls
{
get
{
- List<UserControl> controls = new List<UserControl>();
+ List<Control> controls = new List<Control>();
if (this.DesignMode)
{
@@ -137,7 +137,7 @@
path = dir + "/" + path;
}
- this.uc = (UserControl)this.Page.LoadControl(path);
+ this.uc = (Control)this.Page.LoadControl(path);
if (this.UserControlID.IsNotEmpty())
{
@@ -180,19 +180,19 @@
#endregion
- private ItemsCollection<UserControl> items;
+ private ItemsCollection<Control> items;
/// <summary>
///
/// </summary>
[PersistenceMode(PersistenceMode.InnerProperty)]
- public virtual ItemsCollection<UserControl> Items
+ public virtual ItemsCollection<Control> Items
{
get
{
if (this.items == null)
{
- this.items = new ItemsCollection<UserControl>();
+ this.items = new ItemsCollection<Control>();
this.items.AfterItemAdd += this.AfterUCAdd;
this.items.AfterItemRemove += this.AfterUCRemove;
}
@@ -271,7 +271,7 @@
///
/// </summary>
[Description("")]
- protected virtual void AfterUCAdd(UserControl item)
+ protected virtual void AfterUCAdd(Control item)
{
if (!this.Controls.Contains(item))
{
@@ -308,7 +308,7 @@
///
/// </summary>
[Description("")]
- protected virtual void AfterUCRemove(UserControl item)
+ protected virtual void AfterUCRemove(Control item)
{
if (this.Controls.Contains(item))
{
@@ -362,14 +362,14 @@
/// </summary>
public class UserControlAddedEventArgs : EventArgs
{
- public UserControlAddedEventArgs(UserControl control)
+ public UserControlAddedEventArgs(Control control)
{
this.userControl = control;
}
- private UserControl userControl;
+ private Control userControl;
- public UserControl UserControl
+ public Control UserControl
{
get
{
I will note though that the only control I couldn't get this to work with was asp:ContentPlaceholder. I'd hoped I could do this: <ext:Panel runat="server" Layout="VBoxLayout">
<LayoutConfig>
<ext:VBoxLayoutConfig Align="Stretch" />
</LayoutConfig>
<Items>
<ext:UserControlLoader runat="server">
<Items>
<asp:ContentPlaceHolder id="cp" runat="server" />
</Items>
</ext:UserControlLoader>
</Items>
</ext:Panel>
Last edited by Daniil; Sep 12, 2013 at 3:00 PM.
Reason: [CLOSED]