Property Extender properties not persisting !

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
}
}
 
G

Garry McGlennon

I'm not sure but it looks like you have a similar issue to me... The URL i
posted in my request for help tackles it a different way. I can get it to
persist Ok, but it won't set itself correctly.

Anyway, check out my recently posted message as it 'might' give you some
idea's.

Oh btw, in ASP.NET it stores property values in the HTML not the page like
it does with WinForms, so you should see attributes in your HTML for the
properties (its so late bound!).

Garry Mc
 
J

JezB

ok thanks - i'll take a look

Garry McGlennon said:
I'm not sure but it looks like you have a similar issue to me... The URL i
posted in my request for help tackles it a different way. I can get it to
persist Ok, but it won't set itself correctly.

Anyway, check out my recently posted message as it 'might' give you some
idea's.

Oh btw, in ASP.NET it stores property values in the HTML not the page like
it does with WinForms, so you should see attributes in your HTML for the
properties (its so late bound!).

Garry Mc
 
D

dotnet_vb_newbie

Gary -

I'm having an issue with persistence in a webform provider. I'm
wondering if it sounds like the same problem you had. I've added some
add'l properties to textBox webcontrols. The properies show up and can
be set in the designer. However, if I run the aspx page through the
web, all the new attribute settings disappear.

Another way this shows up is if you set the property values in the
designer, save/close the aspx page and then reopen the aspx page, all
the property values are reset to default.

If this is the same problem, how did you resolve it? It seems really
strange how little info is out there reguarding webcontrol providers...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top