J
JezB
I've written an extender provider for windows forms controls and ASP.NET web
controls. My windows forms solution works fine, but my ASP.NET solution does
not persist any property values I enter via the visual studio property grid.
Upon examination of the code within InitializeComponent I can see why : no
code is automatically embedded to call the Set method of my property.
Anyone have any ideas why ? Is there any solution ?
____________________________________________________________________
using System;
using System.ComponentModel;
using System.Collections;
using System.Diagnostics;
using System.Web.UI.WebControls;
namespace WorkPlace.Presentation.WebLib
{
[ProvideProperty("Key",typeof(WebControl))]
public class FlavourPropertiesExtender :
System.ComponentModel.Component,
IExtenderProvider
{
private System.ComponentModel.Container components = null;
private Hashtable keys;
public FlavourPropertiesExtender(System.ComponentModel.IContainer
container)
{
container.Add(this);
InitializeComponent();
}
public FlavourPropertiesExtender()
{
keys = new Hashtable();
}
[Category("Key Configuration")]
public string GetKey(WebControl c)
{
string text = (string)keys[c];
if (text == null)
{
text = c.ID;
}
return text;
}
public void SetKey(WebControl c, string value)
{
if (value == null)
value = string.Empty;
if (value.Length == 0)
keys.Remove(c);
else
keys[c] = value;
}
#region Component Designer generated code
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
#region IExtenderProvider Members
public bool CanExtend(object extendee)
{
return (extendee is WebControl);
}
#endregion
}
}
controls. My windows forms solution works fine, but my ASP.NET solution does
not persist any property values I enter via the visual studio property grid.
Upon examination of the code within InitializeComponent I can see why : no
code is automatically embedded to call the Set method of my property.
Anyone have any ideas why ? Is there any solution ?
____________________________________________________________________
using System;
using System.ComponentModel;
using System.Collections;
using System.Diagnostics;
using System.Web.UI.WebControls;
namespace WorkPlace.Presentation.WebLib
{
[ProvideProperty("Key",typeof(WebControl))]
public class FlavourPropertiesExtender :
System.ComponentModel.Component,
IExtenderProvider
{
private System.ComponentModel.Container components = null;
private Hashtable keys;
public FlavourPropertiesExtender(System.ComponentModel.IContainer
container)
{
container.Add(this);
InitializeComponent();
}
public FlavourPropertiesExtender()
{
keys = new Hashtable();
}
[Category("Key Configuration")]
public string GetKey(WebControl c)
{
string text = (string)keys[c];
if (text == null)
{
text = c.ID;
}
return text;
}
public void SetKey(WebControl c, string value)
{
if (value == null)
value = string.Empty;
if (value.Length == 0)
keys.Remove(c);
else
keys[c] = value;
}
#region Component Designer generated code
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
#region IExtenderProvider Members
public bool CanExtend(object extendee)
{
return (extendee is WebControl);
}
#endregion
}
}