Extender Provider not saving value

  • Thread starter Thread starter Steven
  • Start date Start date
S

Steven

Hi,

I have implemented the IExtenderProvider interface (and inherited from
Component) in a class that I am using with ASP.NET controls. The field
shows up fine in the VS.NET properties grid, however the value are not
persisted anywhere (I would have expected it to show up in the VS.NET
designer portion of the code), and disapear from the properties page after
compiling. I can manually set it from the code using
provider.SetWhatever(control, object) so I don't think it is not a problem
with the component code.

Any ideas whould be appreciated.

Thanks,

Steven
 
I'm assuming that you have not used a hashtable to associate the value with
the object that owns it.

The Setxxx and Getxxx methods will not store the information automatically.
The following snippet is from a custom tooltip control. Note how each
property is stored in a hashtable with the key being the reference to the
control that has had it's properties extended.

//A utility routing to extract tipData from the hash table using the

//Control reference as a key.

protected tipData GetItem(Control c)

{

if(this._items.Contains(c))

return (tipData)_items[c];

tipData td=new tipData();

_items[c]=td;

c.MouseHover+=new EventHandler(c_MouseHover);

c.MouseLeave+=new EventHandler(c_MouseLeave);

return td;

}

public void SetTipText(Control c, string value)

{

tipData td=GetItem(c);

td.Text=value;

}

public string GetTipText(Control c)

{

tipData td=GetItem(c);

return td.Text;

}


--
Bob Powell [MVP]
C#, System.Drawing

The November edition of Well Formed is now available.
Learn how to create Shell Extensions in managed code.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com
 
I am using a hashtable to store each instance, however I do not have a
GetItem method - could this be the problem?

Bob Powell said:
I'm assuming that you have not used a hashtable to associate the value with
the object that owns it.

The Setxxx and Getxxx methods will not store the information automatically.
The following snippet is from a custom tooltip control. Note how each
property is stored in a hashtable with the key being the reference to the
control that has had it's properties extended.

//A utility routing to extract tipData from the hash table using the

//Control reference as a key.

protected tipData GetItem(Control c)

{

if(this._items.Contains(c))

return (tipData)_items[c];

tipData td=new tipData();

_items[c]=td;

c.MouseHover+=new EventHandler(c_MouseHover);

c.MouseLeave+=new EventHandler(c_MouseLeave);

return td;

}

public void SetTipText(Control c, string value)

{

tipData td=GetItem(c);

td.Text=value;

}

public string GetTipText(Control c)

{

tipData td=GetItem(c);

return td.Text;

}


--
Bob Powell [MVP]
C#, System.Drawing

The November edition of Well Formed is now available.
Learn how to create Shell Extensions in managed code.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

Steven said:
Hi,

I have implemented the IExtenderProvider interface (and inherited from
Component) in a class that I am using with ASP.NET controls. The field
shows up fine in the VS.NET properties grid, however the value are not
persisted anywhere (I would have expected it to show up in the VS.NET
designer portion of the code), and disapear from the properties page after
compiling. I can manually set it from the code using
provider.SetWhatever(control, object) so I don't think it is not a problem
with the component code.

Any ideas whould be appreciated.

Thanks,

Steven
 
Oops.. I wasn't paying enough attention to realize that GetItem is just
being called from SetXX and GetXX.



Bob Powell said:
I'm assuming that you have not used a hashtable to associate the value with
the object that owns it.

The Setxxx and Getxxx methods will not store the information automatically.
The following snippet is from a custom tooltip control. Note how each
property is stored in a hashtable with the key being the reference to the
control that has had it's properties extended.

//A utility routing to extract tipData from the hash table using the

//Control reference as a key.

protected tipData GetItem(Control c)

{

if(this._items.Contains(c))

return (tipData)_items[c];

tipData td=new tipData();

_items[c]=td;

c.MouseHover+=new EventHandler(c_MouseHover);

c.MouseLeave+=new EventHandler(c_MouseLeave);

return td;

}

public void SetTipText(Control c, string value)

{

tipData td=GetItem(c);

td.Text=value;

}

public string GetTipText(Control c)

{

tipData td=GetItem(c);

return td.Text;

}


--
Bob Powell [MVP]
C#, System.Drawing

The November edition of Well Formed is now available.
Learn how to create Shell Extensions in managed code.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

Steven said:
Hi,

I have implemented the IExtenderProvider interface (and inherited from
Component) in a class that I am using with ASP.NET controls. The field
shows up fine in the VS.NET properties grid, however the value are not
persisted anywhere (I would have expected it to show up in the VS.NET
designer portion of the code), and disapear from the properties page after
compiling. I can manually set it from the code using
provider.SetWhatever(control, object) so I don't think it is not a problem
with the component code.

Any ideas whould be appreciated.

Thanks,

Steven
 
Yeah, it was just a little optimization I threw in.

Is your extender-povider working now??

--
Bob Powell [MVP]
C#, System.Drawing

The November edition of Well Formed is now available.
Learn how to create Shell Extensions in managed code.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

Steven said:
Oops.. I wasn't paying enough attention to realize that GetItem is just
being called from SetXX and GetXX.



Bob Powell said:
I'm assuming that you have not used a hashtable to associate the value with
the object that owns it.

The Setxxx and Getxxx methods will not store the information automatically.
The following snippet is from a custom tooltip control. Note how each
property is stored in a hashtable with the key being the reference to the
control that has had it's properties extended.

//A utility routing to extract tipData from the hash table using the

//Control reference as a key.

protected tipData GetItem(Control c)

{

if(this._items.Contains(c))

return (tipData)_items[c];

tipData td=new tipData();

_items[c]=td;

c.MouseHover+=new EventHandler(c_MouseHover);

c.MouseLeave+=new EventHandler(c_MouseLeave);

return td;

}

public void SetTipText(Control c, string value)

{

tipData td=GetItem(c);

td.Text=value;

}

public string GetTipText(Control c)

{

tipData td=GetItem(c);

return td.Text;

}


--
Bob Powell [MVP]
C#, System.Drawing

The November edition of Well Formed is now available.
Learn how to create Shell Extensions in managed code.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

Steven said:
Hi,

I have implemented the IExtenderProvider interface (and inherited from
Component) in a class that I am using with ASP.NET controls. The field
shows up fine in the VS.NET properties grid, however the value are not
persisted anywhere (I would have expected it to show up in the VS.NET
designer portion of the code), and disapear from the properties page after
compiling. I can manually set it from the code using
provider.SetWhatever(control, object) so I don't think it is not a problem
with the component code.

Any ideas whould be appreciated.

Thanks,

Steven
 
No it still wont save the state.. There are similar posts around with no
answers either. Funny, when I use almost the identical code with a windows
form it works fine.
Bob Powell said:
Yeah, it was just a little optimization I threw in.

Is your extender-povider working now??

--
Bob Powell [MVP]
C#, System.Drawing

The November edition of Well Formed is now available.
Learn how to create Shell Extensions in managed code.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

Steven said:
Oops.. I wasn't paying enough attention to realize that GetItem is just
being called from SetXX and GetXX.



Bob Powell said:
I'm assuming that you have not used a hashtable to associate the value with
the object that owns it.

The Setxxx and Getxxx methods will not store the information automatically.
The following snippet is from a custom tooltip control. Note how each
property is stored in a hashtable with the key being the reference to the
control that has had it's properties extended.

//A utility routing to extract tipData from the hash table using the

//Control reference as a key.

protected tipData GetItem(Control c)

{

if(this._items.Contains(c))

return (tipData)_items[c];

tipData td=new tipData();

_items[c]=td;

c.MouseHover+=new EventHandler(c_MouseHover);

c.MouseLeave+=new EventHandler(c_MouseLeave);

return td;

}

public void SetTipText(Control c, string value)

{

tipData td=GetItem(c);

td.Text=value;

}

public string GetTipText(Control c)

{

tipData td=GetItem(c);

return td.Text;

}


--
Bob Powell [MVP]
C#, System.Drawing

The November edition of Well Formed is now available.
Learn how to create Shell Extensions in managed code.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

Hi,

I have implemented the IExtenderProvider interface (and inherited from
Component) in a class that I am using with ASP.NET controls. The field
shows up fine in the VS.NET properties grid, however the value are not
persisted anywhere (I would have expected it to show up in the VS.NET
designer portion of the code), and disapear from the properties page after
compiling. I can manually set it from the code using
provider.SetWhatever(control, object) so I don't think it is not a problem
with the component code.

Any ideas whould be appreciated.

Thanks,

Steven
 
Back
Top