This is a migrated thread and some comments may be shown as answers.

Inherit from RadPanelBarEventArgs

2 Answers 49 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 23 Jun 2011, 04:59 PM

I'm trying to add some extended properties to a RadPanelItem like so:

Public Class RadPanelItemExtended
Inherits Telerik.Web.UI.RadPanelItem
Private _HasChildren As Boolean
Public Property HasChildren() As Boolean
Get
Return _HasChildren
End Get
Set(ByVal value As Boolean)
_HasChildren = value
End Set
End Property
End Class

To access the extended properties on RadPanelBar.ItemClick i need to make the RadPanelBarEventArgs handle RadPanelItemExtended class rather than RadPanelItem class. I thought this was possible through creating an extended eventargs class like so:

 

Public Class RadPanelBarEventArgsExtended
Inherits Telerik.Web.UI.RadPanelBarEventArgs
Private _RadPanelItemExtended As RadPanelItemExtended
Public Property RadPanelItemExtended() As RadPanelItemExtended
Get
Return _RadPanelItemExtended
End Get
Set(ByVal value As RadPanelItemExtended)
_RadPanelItemExtended = value
End Set
End Property
Sub New(ByVal item As RadPanelItemExtended)
MyBase.New(item)
Me._RadPanelItemExtended = item
End Sub

When using these extended classes like this:

Protected Sub RadPanelBar_ItemClick(ByVal sender As Object, ByVal e As RadPanelBarEventArgsExtended) Handles RadPanelBar.ItemClick
End Sub

I get the following error:
Unable to cast object of type 'Telerik.Web.UI.RadPanelBarEventArgs' to type 'RadPanelBarEventArgsExtended'.

Why is this?

Regards
Richard

2 Answers, 1 is accepted

Sort by
0
Richard
Top achievements
Rank 1
answered on 28 Jun 2011, 10:13 PM
Has anyone had time to look into this yet?

Regards Richard
0
Peter
Telerik team
answered on 29 Jun 2011, 03:49 PM
Hello Richard,

You might also need to extend the RadPanelBar because of its ItemClick delegate.

I wonder if you can use a simpler approach - you can easily create a method that checks if an item has children and use it when needed. Are there any specific reasons why you cannot use this method?

Best wishes,
Peter
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
PanelBar
Asked by
Richard
Top achievements
Rank 1
Answers by
Richard
Top achievements
Rank 1
Peter
Telerik team
Share this question
or