Monday, March 26, 2012

How do I extend an Atlas extender?

Let's say I create my own Atlas Control Extender. For example, I create an extender called MyHoverExtender. But instead of extending Control or WebControl, I want to extend the HoverMenuExtender. But when I change it to use that, I get this error:

error BC32044: Type argument 'SearchResultItem.MyHoverExtenderProperties' does not inherit from or implement the constraint type 'Microsoft.AtlasControlExtender.TargetControlPropertiesBase(Of AtlasControlToolkit.HoverMenuExtender)'.

Can anyone help me with this error?

Thanks

The extender class and the properties class have to travel in pairs. So if you derive from the extender, you need to also do so from the properties class. I think if you just have your MyHoverExtenderProperties class inherit from HoverMenuProperties you should be OK.



So here's what I've got right now:

-----------------

MyHoverExtenderDesigner.vb:

Class MyHoverExtenderDesigner
Inherits Microsoft.AtlasControlExtender.Design.ExtenderControlBaseDesigner(Of MyHoverExtenderProperties, AtlasControlToolkit.HoverMenuExtender)
End Class

Produces this error:

error BC32044: Type argument 'SearchResultItem.MyHoverExtenderProperties' does not inherit from or implement the constraint type 'Microsoft.AtlasControlExtender.TargetControlPropertiesBase(Of AtlasControlToolkit.HoverMenuExtender)'.

-----------------

MyHoverExtenderExtender.vb:

<Assembly: System.Web.UI.WebResource("SearchResultItem.MyHoverExtenderBehavior.js", "text/javascript")>

<System.ComponentModel.Designer(GetType(MyHoverExtenderDesigner))> _
<Microsoft.AtlasControlExtender.ClientScriptResource("MyHoverExtender", "MyHoverExtenderBehavior", "SearchResultItem.MyHoverExtenderBehavior.js")> _
Public Class MyHoverExtenderExtender
Inherits Microsoft.AtlasControlExtender.ExtenderControlBase(Of MyHoverExtenderProperties, AtlasControlToolkit.HoverMenuExtender)
End Class

Produces this error:

error BC32044: Type argument 'SearchResultItem.MyHoverExtenderProperties' does not inherit from or implement the constraint type 'Microsoft.AtlasControlExtender.TargetControlPropertiesBase(Of AtlasControlToolkit.HoverMenuExtender)'.

-----------------

MyHoverExtenderProperties.vb

<System.ComponentModel.DefaultProperty("MyProperty")> _
Public Class MyHoverExtenderProperties
Inherits Microsoft.AtlasControlExtender.TargetControlPropertiesBase(Of AtlasControlToolkit.HoverMenuProperties)

Public Property MyProperty() As String
Get
Return GetPropertyStringValue("MyProperty")
End Get
Set(ByVal value As String)
SetPropertyStringValue("MyProperty", value)
End Set
End Property

End Class

This file builds without any errors as far as I can tell.


Oh, sorry, just find my problem.

The MyHoverExtenderProperties class was declared thusly:

Public Class MyHoverExtenderProperties
Inherits Microsoft.AtlasControlExtender.TargetControlPropertiesBase(Of AtlasControlToolkit.HoverMenuProperties)

But it should be declared:

Public Class MyHoverExtenderProperties
Inherits Microsoft.AtlasControlExtender.TargetControlPropertiesBase(Of AtlasControlToolkit.HoverMenuExtender)


That's closer. Does that work?

I think you actually want:

public class MyHoverExtender inherits HoverMenuExtender

public class MyHoverExtenderProperties inherits HoverMenuProperties

What you have above says that you'll be extending controls of type HoverMenuExtender, which I don't think you want.


Yeah, I think you're right. I'm in the process of confusing myself today between wanting to extend my own custom control using a modified version of the hover extender. I think I've almost got my head around it all.

:) Okay if you want more help confusing yourself, just let us know and we'll be glad to lend a hand.

Seriously, our refresh should help with this - I'm concerned you may run into some issues getting the right scripts to load as is. I haven't tried what you're doing so do let us know.

No comments:

Post a Comment